From da17453a43a438042980a16478bc9338b55af89a Mon Sep 17 00:00:00 2001 From: Jose Perez Rodriguez Date: Tue, 17 Mar 2026 19:57:30 -0700 Subject: [PATCH 01/49] [release/13.2] Stabilizing builds in preparation for 13.2 release (#15323) * Update package versions to 13.2.0 and enable stabilization in CI configuration * Temporary marking some integrations as preview while we wait for Azure.Provisioning.PrivateDns package * Update packaging service to set pre-release channel quality to 'Both' for pr hives * Update CLI E2E version check to handle stabilized builds When StabilizePackageVersion=true, aspire --version outputs just '13.2.0' without a commit SHA suffix. Update VerifyAspireCliVersionAsync to check for '13.2.0' which is present in both stable and prerelease version strings. Suppress IDE0060 for the unused commitSha parameter rather than removing it, so it can be restored when merging back to main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Skip preview-only packages in TypeScript polyglot validation Packages with SuppressFinalPackageVersion=true only produce prerelease versions, which causes aspire restore to fail when the build is stabilized (it requests stable versions). Skip these packages until the build infrastructure dynamically computes versions (#15335). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 22 --- .../test-typescript-playground.sh | 38 ++++- eng/Versions.props | 2 +- src/Aspire.Cli/Packaging/PackagingService.cs | 2 +- .../Aspire.Hosting.Azure.Network.csproj | 3 + .../Aspire.Hosting.Azure.Sql.csproj | 3 + .../Helpers/CliE2EAutomatorHelpers.cs | 19 +-- .../RepoTesting/Aspire.RepoTesting.targets | 4 +- .../Directory.Packages.Helix.props | 138 +++++++++--------- 9 files changed, 126 insertions(+), 105 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc39f93bf69..43d27085e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,6 @@ jobs: if: ${{ github.repository_owner == 'dotnet' }} outputs: skip_workflow: ${{ (steps.check_for_changes.outputs.no_changes == 'true' || steps.check_for_changes.outputs.only_changed == 'true') && 'true' || 'false' }} - VERSION_SUFFIX_OVERRIDE: ${{ steps.compute_version_suffix.outputs.VERSION_SUFFIX_OVERRIDE }} steps: - name: Checkout code @@ -39,32 +38,11 @@ jobs: with: patterns_file: eng/testing/github-ci-trigger-patterns.txt - - id: compute_version_suffix - name: Compute version suffix for PRs - if: ${{ github.event_name == 'pull_request' }} - shell: pwsh - env: - # Use the pull request head SHA instead of GITHUB_SHA (which can be a merge commit) - PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - PR_NUMBER: ${{ github.event.number }} - run: | - Write-Host "Determining VERSION_SUFFIX_OVERRIDE (PR only step)..." - if ([string]::IsNullOrWhiteSpace($Env:PR_HEAD_SHA)) { - Write-Error "PR_HEAD_SHA not set; cannot compute version suffix." - exit 1 - } - $SHORT_SHA = $Env:PR_HEAD_SHA.Substring(0,8) - $VERSION_SUFFIX = "/p:VersionSuffix=pr.$($Env:PR_NUMBER).g$SHORT_SHA" - Write-Host "Computed VERSION_SUFFIX_OVERRIDE=$VERSION_SUFFIX" - "VERSION_SUFFIX_OVERRIDE=$VERSION_SUFFIX" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append -Encoding utf8 - tests: uses: ./.github/workflows/tests.yml name: Tests needs: [prepare_for_ci] if: ${{ github.repository_owner == 'dotnet' && needs.prepare_for_ci.outputs.skip_workflow != 'true' }} - with: - versionOverrideArg: ${{ needs.prepare_for_ci.outputs.VERSION_SUFFIX_OVERRIDE }} # This job is used for branch protection. It fails if any of the dependent jobs failed results: diff --git a/.github/workflows/polyglot-validation/test-typescript-playground.sh b/.github/workflows/polyglot-validation/test-typescript-playground.sh index cd214826588..d5125f3fb22 100644 --- a/.github/workflows/polyglot-validation/test-typescript-playground.sh +++ b/.github/workflows/polyglot-validation/test-typescript-playground.sh @@ -55,9 +55,45 @@ echo "" FAILED=() PASSED=() +SKIPPED=() + +# Packages that only produce prerelease versions (SuppressFinalPackageVersion=true) cannot be +# restored when the build is stabilized, because aspire restore requests stable versions. +# Skip these until the build infrastructure dynamically computes versions. See #15335. +SKIP_PREVIEW_ONLY=( + "Aspire.Hosting.Azure.Kusto" + "Aspire.Hosting.Azure.Network" + "Aspire.Hosting.Azure.Sql" + "Aspire.Hosting.Docker" + "Aspire.Hosting.Foundry" + "Aspire.Hosting.Keycloak" + "Aspire.Hosting.Kubernetes" + "Aspire.Hosting.Maui" +) for app_dir in "${APP_DIRS[@]}"; do app_name="$(basename "$(dirname "$app_dir")")/$(basename "$app_dir")" + integration_name="$(basename "$(dirname "$app_dir")")" + + # Check if this integration is in the skip list + skip=false + for skip_pkg in "${SKIP_PREVIEW_ONLY[@]}"; do + if [ "$integration_name" = "$skip_pkg" ]; then + skip=true + break + fi + done + + if [ "$skip" = true ]; then + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "Testing: $app_name" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo " ⏭ Skipping (preview-only package, see #15335)" + SKIPPED+=("$app_name") + echo "" + continue + fi + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "Testing: $app_name" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" @@ -97,7 +133,7 @@ done echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "Results: ${#PASSED[@]} passed, ${#FAILED[@]} failed out of ${#APP_DIRS[@]} apps" +echo "Results: ${#PASSED[@]} passed, ${#FAILED[@]} failed, ${#SKIPPED[@]} skipped out of ${#APP_DIRS[@]} apps" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" if [ ${#FAILED[@]} -gt 0 ]; then diff --git a/eng/Versions.props b/eng/Versions.props index 5bdea3c29f8..e83d5c79f44 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -21,7 +21,7 @@ 1.8.4 17.14.1 - false + true release diff --git a/src/Aspire.Cli/Packaging/PackagingService.cs b/src/Aspire.Cli/Packaging/PackagingService.cs index d1e91bc06d4..8f634b7372f 100644 --- a/src/Aspire.Cli/Packaging/PackagingService.cs +++ b/src/Aspire.Cli/Packaging/PackagingService.cs @@ -44,7 +44,7 @@ public Task> GetChannelsAsync(CancellationToken canc // The packages subdirectory contains the actual .nupkg files // Use forward slashes for cross-platform NuGet config compatibility var packagesPath = Path.Combine(prHive.FullName, "packages").Replace('\\', '/'); - var prChannel = PackageChannel.CreateExplicitChannel(prHive.Name, PackageChannelQuality.Prerelease, new[] + var prChannel = PackageChannel.CreateExplicitChannel(prHive.Name, PackageChannelQuality.Both, new[] { new PackageMapping("Aspire*", packagesPath), new PackageMapping(PackageMapping.AllPackages, "https://api.nuget.org/v3/index.json") diff --git a/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj b/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj index dc9b9da99dc..61e6b282c7e 100644 --- a/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj +++ b/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj @@ -6,6 +6,9 @@ aspire integration hosting azure network vnet virtual-network subnet nat-gateway public-ip cloud Azure Virtual Network resource types for Aspire. $(SharedDir)Azure_256x.png + + true true $(NoWarn);AZPROVISION001;ASPIREAZURE003 diff --git a/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj b/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj index b5a93be6e67..dfb9a374f5c 100644 --- a/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj +++ b/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj @@ -7,6 +7,9 @@ aspire integration hosting azure sql database data cloud Azure SQL Database resource types for Aspire. $(SharedDir)AzureSqlServer_256x.png + + true diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs index a9cf8d2e89a..d4a4ad86fa6 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs @@ -147,23 +147,24 @@ internal static async Task SourceAspireCliEnvironmentAsync( } /// - /// Verifies the installed Aspire CLI version matches the expected commit SHA. + /// Verifies the installed Aspire CLI version matches the expected version. /// +#pragma warning disable IDE0060 // commitSha is unused during stabilized builds — restore when merging back to main internal static async Task VerifyAspireCliVersionAsync( this Hex1bTerminalAutomator auto, string commitSha, SequenceCounter counter) +#pragma warning restore IDE0060 { - if (commitSha.Length != 40) - { - throw new ArgumentException($"Commit SHA must be exactly 40 characters, got {commitSha.Length}: '{commitSha}'", nameof(commitSha)); - } - - var shortCommitSha = commitSha[..8]; - var expectedVersionSuffix = $"g{shortCommitSha}"; await auto.TypeAsync("aspire --version"); await auto.EnterAsync(); - await auto.WaitUntilTextAsync(expectedVersionSuffix, timeout: TimeSpan.FromSeconds(10)); + + // When the build is stabilized (StabilizePackageVersion=true), the CLI version + // is just "13.2.0" with no commit SHA suffix. When not stabilized, it includes + // the SHA (e.g., "13.2.0-preview.1.g"). In both cases, "13.2.0" is present. + // TODO: This change should be reverted on the integration to the main branch. + await auto.WaitUntilTextAsync("13.2.0", timeout: TimeSpan.FromSeconds(10)); + await auto.WaitForSuccessPromptAsync(counter); } diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets index e29d62d1ac8..7b2650bea51 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets @@ -33,7 +33,7 @@ `AspireProjectOrPackageReference` - maps to projects in `src/` or `src/Components/` --> - + @@ -165,6 +165,6 @@ $(MajorVersion).$(MinorVersion).$(PatchVersion) - + diff --git a/tests/Shared/RepoTesting/Directory.Packages.Helix.props b/tests/Shared/RepoTesting/Directory.Packages.Helix.props index 5428992b1ba..d7a1766e843 100644 --- a/tests/Shared/RepoTesting/Directory.Packages.Helix.props +++ b/tests/Shared/RepoTesting/Directory.Packages.Helix.props @@ -3,81 +3,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + From 777972ef24ab504c0a50667315f5102035096a96 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 10:53:02 -0700 Subject: [PATCH 02/49] Remove redundant Path.GetDirectoryName call and rename _appPath/_AppPath to _appDirectoryPath/AppDirectoryPath in PrebuiltAppHostServer (#15332) * Initial plan * Remove Path.GetDirectoryName call and rename _appPath to _appDirectoryPath in PrebuiltAppHostServer Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com> * Rename AppPath property to AppDirectoryPath in IAppHostServerProject and implementations Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com> --- .../DotNetBasedAppHostServerProject.cs | 2 +- .../Projects/IAppHostServerProject.cs | 2 +- .../Projects/PrebuiltAppHostServer.cs | 18 ++++++++---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs b/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs index eb58875f4a7..484a2da84bb 100644 --- a/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs +++ b/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs @@ -97,7 +97,7 @@ public DotNetBasedAppHostServerProject( } /// - public string AppPath => _appPath; + public string AppDirectoryPath => _appPath; public string ProjectModelPath => _projectModelPath; public string UserSecretsId => _userSecretsId; diff --git a/src/Aspire.Cli/Projects/IAppHostServerProject.cs b/src/Aspire.Cli/Projects/IAppHostServerProject.cs index 8c19179b308..a5fc0730826 100644 --- a/src/Aspire.Cli/Projects/IAppHostServerProject.cs +++ b/src/Aspire.Cli/Projects/IAppHostServerProject.cs @@ -31,7 +31,7 @@ internal interface IAppHostServerProject /// /// Gets the path to the user's app (the polyglot apphost directory). /// - string AppPath { get; } + string AppDirectoryPath { get; } /// /// Prepares the AppHost server for running. diff --git a/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs b/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs index 7bfdb9e3100..d263b743db1 100644 --- a/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs +++ b/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs @@ -24,7 +24,7 @@ namespace Aspire.Cli.Projects; /// internal sealed class PrebuiltAppHostServer : IAppHostServerProject { - private readonly string _appPath; + private readonly string _appDirectoryPath; private readonly string _socketPath; private readonly LayoutConfiguration _layout; private readonly BundleNuGetService _nugetService; @@ -41,7 +41,7 @@ internal sealed class PrebuiltAppHostServer : IAppHostServerProject /// /// Initializes a new instance of the PrebuiltAppHostServer class. /// - /// The path to the user's polyglot app host directory. + /// The path to the user's polyglot app host directory (must be a directory path). /// The socket path for JSON-RPC communication. /// The bundle layout configuration. /// The NuGet service for restoring integration packages (NuGet-only path). @@ -61,7 +61,7 @@ public PrebuiltAppHostServer( IConfigurationService configurationService, ILogger logger) { - _appPath = Path.GetFullPath(appPath); + _appDirectoryPath = Path.GetFullPath(appPath); _socketPath = socketPath; _layout = layout; _nugetService = nugetService; @@ -72,14 +72,14 @@ public PrebuiltAppHostServer( _logger = logger; // Create a working directory for this app host session - var pathHash = SHA256.HashData(Encoding.UTF8.GetBytes(_appPath)); + var pathHash = SHA256.HashData(Encoding.UTF8.GetBytes(_appDirectoryPath)); var pathDir = Convert.ToHexString(pathHash)[..12].ToLowerInvariant(); _workingDirectory = Path.Combine(Path.GetTempPath(), ".aspire", "bundle-hosts", pathDir); Directory.CreateDirectory(_workingDirectory); } /// - public string AppPath => _appPath; + public string AppDirectoryPath => _appDirectoryPath; /// /// Gets the path to the aspire-managed executable (used as the server). @@ -171,13 +171,11 @@ private async Task RestoreNuGetPackagesAsync( var packages = packageRefs.Select(r => (r.Name, r.Version!)).ToList(); var sources = await GetNuGetSourcesAsync(channelName, cancellationToken); - var appHostDirectory = Path.GetDirectoryName(_appPath); - return await _nugetService.RestorePackagesAsync( packages, DotNetBasedAppHostServerProject.TargetFramework, sources: sources, - workingDirectory: appHostDirectory, + workingDirectory: _appDirectoryPath, ct: cancellationToken); } @@ -337,7 +335,7 @@ internal static string GenerateIntegrationProjectFile( private async Task ResolveChannelNameAsync(CancellationToken cancellationToken) { // Check local settings.json first - var localConfig = AspireJsonConfiguration.Load(Path.GetDirectoryName(_appPath)!); + var localConfig = AspireJsonConfiguration.Load(_appDirectoryPath); var channelName = localConfig?.Channel; // Fall back to global config @@ -506,7 +504,7 @@ internal static string GenerateIntegrationProjectFile( } /// - public string GetInstanceIdentifier() => _appPath; + public string GetInstanceIdentifier() => _appDirectoryPath; /// /// Reads the project reference assembly names written by the MSBuild target during build. From 0b31e3d716bd22c6f288478a238874d500d0b101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Wed, 18 Mar 2026 10:56:24 -0700 Subject: [PATCH 03/49] Fix Foundry run-mode project restart (#15342) * Fix Foundry run-mode project restart Ensure the default Foundry ACR is registered in run mode so project provisioning can restore its dependent outputs on restart. Add a regression test covering run-mode default container registry registration for Foundry projects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update Foundry run-mode test expectation Adjust the Foundry run-mode project test to expect the default container registry to be modeled in the app resources now that restart provisioning depends on it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Block Foundry projects on local mode Throw a clear InvalidOperationException when AddProject is combined with RunAsFoundryLocal in either order, and add tests covering both unsupported scenarios. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../FoundryExtensions.cs | 12 +++++++++ .../Project/ProjectBuilderExtension.cs | 9 ++++--- .../FoundryExtensionsTests.cs | 14 ++++++++++ .../AddProjectTests.cs | 26 +++++++++++++++++++ .../ProjectResourceTests.cs | 4 ++- 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/Aspire.Hosting.Foundry/FoundryExtensions.cs b/src/Aspire.Hosting.Foundry/FoundryExtensions.cs index 7a743712494..ddd6f2e8893 100644 --- a/src/Aspire.Hosting.Foundry/FoundryExtensions.cs +++ b/src/Aspire.Hosting.Foundry/FoundryExtensions.cs @@ -23,6 +23,7 @@ namespace Aspire.Hosting; public static class FoundryExtensions { private const string DefaultCapabilityHostName = "foundry-caphost"; + internal const string LocalProjectsNotSupportedMessage = "Microsoft Foundry projects are not supported when the parent Foundry resource is configured with RunAsFoundryLocal()."; /// /// Adds a Microsoft Foundry resource to the application model. @@ -140,6 +141,7 @@ public static IResourceBuilder RunAsFoundryLocal(this IResource } var resource = builder.Resource; + ThrowIfProjectsConfiguredForLocal(builder, resource); resource.Annotations.Add(new EmulatorResourceAnnotation()); builder.ApplicationBuilder.Services.AddSingleton(); @@ -169,6 +171,16 @@ public static IResourceBuilder RunAsFoundryLocal(this IResource return builder; } + internal static void ThrowIfProjectsConfiguredForLocal(IResourceBuilder builder, FoundryResource resource) + { + if (builder.ApplicationBuilder.Resources + .OfType() + .Any(project => ReferenceEquals(project.Parent, resource))) + { + throw new InvalidOperationException(LocalProjectsNotSupportedMessage); + } + } + /// /// Assigns the specified roles to the given resource, granting it the necessary permissions /// on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. diff --git a/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs b/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs index bc84e4d83ed..7a4ad61dcae 100644 --- a/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs +++ b/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs @@ -41,6 +41,10 @@ public static IResourceBuilder AddProject { ArgumentNullException.ThrowIfNull(builder); ArgumentException.ThrowIfNullOrEmpty(name); + if (builder.Resource.IsEmulator) + { + throw new InvalidOperationException(FoundryExtensions.LocalProjectsNotSupportedMessage); + } builder.ApplicationBuilder.Services.Configure(o => o.SupportsTargetedRoleAssignments = true); @@ -598,10 +602,7 @@ static void configureInfrastructure(AzureResourceInfrastructure infrastructure) } var resource = new AzureContainerRegistryResource(name, configureInfrastructure); - if (builder.ExecutionContext.IsPublishMode) - { - builder.AddResource(resource); - } + builder.AddResource(resource); return resource; } } diff --git a/tests/Aspire.Hosting.Azure.Tests/FoundryExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/FoundryExtensionsTests.cs index 41b2dfdc90f..4729d4cf244 100644 --- a/tests/Aspire.Hosting.Azure.Tests/FoundryExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/FoundryExtensionsTests.cs @@ -194,6 +194,20 @@ public void AddProject_SetsParentFoundryForProvisioningOrdering() Assert.Same(foundry.Resource, project.Resource.Parent); } + [Fact] + public void AddProject_AddsDefaultContainerRegistryInRunMode() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + + var project = builder.AddFoundry("myAIFoundry") + .AddProject("my-project"); + + var registry = Assert.Single(builder.Resources.OfType()); + + Assert.Equal("my-project-acr", registry.Name); + Assert.Same(registry, project.Resource.ContainerRegistry); + } + [Fact] public async Task AddProject_WithPublishAsExistingFoundry_GeneratesBicepThatReferencesExistingParent() { diff --git a/tests/Aspire.Hosting.Foundry.Tests/AddProjectTests.cs b/tests/Aspire.Hosting.Foundry.Tests/AddProjectTests.cs index 639b7f5f9b9..93c80aab616 100644 --- a/tests/Aspire.Hosting.Foundry.Tests/AddProjectTests.cs +++ b/tests/Aspire.Hosting.Foundry.Tests/AddProjectTests.cs @@ -43,4 +43,30 @@ public async Task AddProject_WithReference_ShouldBindUriConnectionProperty() && value is "{test-project.outputs.endpoint}"; }); } + + [Fact] + public void AddProject_AfterRunAsFoundryLocal_Throws() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + + var foundry = builder.AddFoundry("account") + .RunAsFoundryLocal(); + + var exception = Assert.Throws(() => foundry.AddProject("my-project")); + + Assert.Equal(FoundryExtensions.LocalProjectsNotSupportedMessage, exception.Message); + } + + [Fact] + public void RunAsFoundryLocal_AfterAddProject_Throws() + { + using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run); + + var foundry = builder.AddFoundry("account"); + foundry.AddProject("my-project"); + + var exception = Assert.Throws(foundry.RunAsFoundryLocal); + + Assert.Equal(FoundryExtensions.LocalProjectsNotSupportedMessage, exception.Message); + } } diff --git a/tests/Aspire.Hosting.Foundry.Tests/ProjectResourceTests.cs b/tests/Aspire.Hosting.Foundry.Tests/ProjectResourceTests.cs index 6b12b3b4940..e83afad02f7 100644 --- a/tests/Aspire.Hosting.Foundry.Tests/ProjectResourceTests.cs +++ b/tests/Aspire.Hosting.Foundry.Tests/ProjectResourceTests.cs @@ -42,7 +42,9 @@ public void AddProject_InRunMode_ModelsDefaultContainerRegistry() var project = builder.AddFoundry("account") .AddProject("my-project"); - Assert.Empty(builder.Resources.OfType()); + var registry = Assert.Single(builder.Resources.OfType()); + Assert.Equal("my-project-acr", registry.Name); + Assert.Same(project.Resource.DefaultContainerRegistry, registry); Assert.Same(project.Resource.DefaultContainerRegistry, project.Resource.ContainerRegistry); } From 8e4a4b44540280c28e34ce74a420c6a821eb31b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Wed, 18 Mar 2026 12:58:24 -0700 Subject: [PATCH 04/49] Fix Aspire.Hosting analyzer hookup (#15338) * Fix Aspire.Hosting analyzer hookup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix analyzer export after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove global namespace qualifiers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refresh codegen snapshots Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix TypeScript capability assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix shared configuration export ignore Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address analyzer review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refresh container capability snapshot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Infrastructure/WellKnownTypeData.cs | 4 + .../AspireExportAnalyzer.cs | 179 +++++++++++----- .../AtsCapabilityScanner.cs | 6 +- .../DistributedApplicationModelExtensions.cs | 3 + .../ProjectResourceExtensions.cs | 2 + .../ApplicationModel/ResourceExtensions.cs | 23 +++ src/Aspire.Hosting/Aspire.Hosting.csproj | 5 - .../Ats/AspireExportIgnoreAttribute.cs | 8 +- .../ConnectionPropertiesExtensions.cs | 3 +- .../ConnectionStringBuilderExtensions.cs | 2 +- .../ContainerExecutableResourceExtensions.cs | 1 + .../ContainerResourceBuilderExtensions.cs | 4 +- .../ContainerResourceExtensions.cs | 2 + .../EmulatorResourceExtensions.cs | 1 + .../ExecutableResourceBuilderExtensions.cs | 2 +- .../ExecutableResourceExtensions.cs | 1 + .../ProjectResourceBuilderExtensions.cs | 6 +- .../Publishing/PublishingExtensions.cs | 1 + .../ResourceBuilderExtensions.cs | 17 +- src/Aspire.Hosting/Utils/ExtensionUtils.cs | 1 + src/Aspire.TypeSystem/AttributeDataReader.cs | 6 + src/Directory.Build.targets | 2 +- src/Shared/IConfigurationExtensions.cs | 12 ++ .../AspireExportAnalyzerTests.cs | 147 +++++++++++++ ...TwoPassScanningGeneratedAspire.verified.go | 164 ++++++++------- ...oPassScanningGeneratedAspire.verified.java | 154 +++++++------- ...TwoPassScanningGeneratedAspire.verified.py | 150 +++++++------- ...TwoPassScanningGeneratedAspire.verified.rs | 156 +++++++------- ...ContainerResourceCapabilities.verified.txt | 84 ++++---- ...TwoPassScanningGeneratedAspire.verified.ts | 194 +++++++++++------- .../AttributeDataReaderTests.cs | 13 ++ 31 files changed, 882 insertions(+), 471 deletions(-) diff --git a/src/Aspire.Hosting.Analyzers/Infrastructure/WellKnownTypeData.cs b/src/Aspire.Hosting.Analyzers/Infrastructure/WellKnownTypeData.cs index dbf8b3da47d..44770f9677e 100644 --- a/src/Aspire.Hosting.Analyzers/Infrastructure/WellKnownTypeData.cs +++ b/src/Aspire.Hosting.Analyzers/Infrastructure/WellKnownTypeData.cs @@ -19,6 +19,8 @@ public enum WellKnownType Aspire_Hosting_IDistributedApplicationBuilder, System_Threading_Tasks_Task, System_Threading_Tasks_Task_1, + System_Threading_Tasks_ValueTask, + System_Threading_Tasks_ValueTask_1, // Date/time and scalar types System_DateTimeOffset, @@ -52,6 +54,8 @@ public enum WellKnownType "Aspire.Hosting.IDistributedApplicationBuilder", "System.Threading.Tasks.Task", "System.Threading.Tasks.Task`1", + "System.Threading.Tasks.ValueTask", + "System.Threading.Tasks.ValueTask`1", // Date/time and scalar types "System.DateTimeOffset", diff --git a/src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.cs b/src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.cs index eec5cb99ba8..cd857a02910 100644 --- a/src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.cs +++ b/src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.cs @@ -48,6 +48,8 @@ private void AnalyzeCompilationStart(CompilationStartAnalysisContext context) return; } + var currentAssemblyExportedTypes = GetAssemblyExportedTypes(context.Compilation.Assembly, aspireExportAttribute); + // Try to get AspireExportIgnoreAttribute for ASPIREEXPORT008 INamedTypeSymbol? aspireExportIgnoreAttribute = null; try @@ -75,7 +77,7 @@ private void AnalyzeCompilationStart(CompilationStartAnalysisContext context) var exportsByKey = new ConcurrentDictionary<(string ExportId, string TargetType), ConcurrentBag<(IMethodSymbol Method, Location Location)>>(); context.RegisterSymbolAction( - c => AnalyzeMethod(c, wellKnownTypes, aspireExportAttribute, aspireExportIgnoreAttribute, aspireUnionAttribute, exportsByKey), + c => AnalyzeMethod(c, wellKnownTypes, aspireExportAttribute, aspireExportIgnoreAttribute, aspireUnionAttribute, currentAssemblyExportedTypes, exportsByKey), SymbolKind.Method); // At the end of compilation, report duplicate export IDs @@ -120,6 +122,7 @@ private static void AnalyzeMethod( INamedTypeSymbol aspireExportAttribute, INamedTypeSymbol? aspireExportIgnoreAttribute, INamedTypeSymbol? aspireUnionAttribute, + HashSet currentAssemblyExportedTypes, ConcurrentDictionary<(string ExportId, string TargetType), ConcurrentBag<(IMethodSymbol Method, Location Location)>> exportsByKey) { var method = (IMethodSymbol)context.Symbol; @@ -145,10 +148,23 @@ private static void AnalyzeMethod( } } + var containingTypeHasExportIgnore = false; + if (!hasExportIgnore && aspireExportIgnoreAttribute is not null) + { + foreach (var attr in method.ContainingType.GetAttributes()) + { + if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass, aspireExportIgnoreAttribute)) + { + containingTypeHasExportIgnore = true; + break; + } + } + } + // ASPIREEXPORT008: Check for missing export attributes on builder extension methods - if (exportAttribute is null && !hasExportIgnore && !isObsolete) + if (exportAttribute is null && !hasExportIgnore && !containingTypeHasExportIgnore && !isObsolete) { - AnalyzeMissingExportAttribute(context, method, wellKnownTypes, aspireExportAttribute); + AnalyzeMissingExportAttribute(context, method, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } if (exportAttribute is null) @@ -158,9 +174,10 @@ private static void AnalyzeMethod( var attributeSyntax = exportAttribute.ApplicationSyntaxReference?.GetSyntax(context.CancellationToken); var location = attributeSyntax?.GetLocation() ?? method.Locations.FirstOrDefault() ?? Location.None; + var containingTypeExportAttribute = GetContainingTypeAspireExportAttribute(method.ContainingType, aspireExportAttribute); // Rule 1: Method must be static - if (!method.IsStatic) + if (!method.IsStatic && containingTypeExportAttribute is null) { context.ReportDiagnostic(Diagnostic.Create( Diagnostics.s_exportMethodMustBeStatic, @@ -179,7 +196,7 @@ private static void AnalyzeMethod( } // Rule 3: Validate return type is ATS-compatible - if (!IsAtsCompatibleType(method.ReturnType, wellKnownTypes, aspireExportAttribute)) + if (!IsAtsCompatibleType(method.ReturnType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { context.ReportDiagnostic(Diagnostic.Create( Diagnostics.s_returnTypeMustBeAtsCompatible, @@ -191,7 +208,7 @@ private static void AnalyzeMethod( // Rule 4: Validate parameter types are ATS-compatible foreach (var parameter in method.Parameters) { - if (!IsAtsCompatibleParameter(parameter, wellKnownTypes, aspireExportAttribute)) + if (!IsAtsCompatibleParameter(parameter, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { context.ReportDiagnostic(Diagnostic.Create( Diagnostics.s_parameterTypeMustBeAtsCompatible, @@ -204,7 +221,7 @@ private static void AnalyzeMethod( // Rule 5 (ASPIREEXPORT005/006): Validate [AspireUnion] on parameters if (aspireUnionAttribute is not null) { - AnalyzeUnionAttribute(context, parameter.GetAttributes(), aspireUnionAttribute, wellKnownTypes, aspireExportAttribute); + AnalyzeUnionAttribute(context, parameter.GetAttributes(), aspireUnionAttribute, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } } @@ -229,7 +246,8 @@ private static void AnalyzeMissingExportAttribute( SymbolAnalysisContext context, IMethodSymbol method, WellKnownTypes wellKnownTypes, - INamedTypeSymbol aspireExportAttribute) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { // Only check public static extension methods if (!method.IsStatic || !method.IsExtensionMethod || method.DeclaredAccessibility != Accessibility.Public) @@ -244,13 +262,13 @@ private static void AnalyzeMissingExportAttribute( // Only check methods extending exported handle types that participate in ATS. var firstParamType = method.Parameters[0].Type; - if (!RequiresExplicitExportCoverage(firstParamType, wellKnownTypes, aspireExportAttribute)) + if (!RequiresExplicitExportCoverage(firstParamType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { return; } // Determine the incompatibility reason (if any) to include in the warning - var reason = GetIncompatibilityReason(method, wellKnownTypes, aspireExportAttribute); + var reason = GetIncompatibilityReason(method, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); var location = method.Locations.FirstOrDefault() ?? Location.None; context.ReportDiagnostic(Diagnostic.Create( @@ -505,8 +523,10 @@ private static bool IsOpenGenericResourceBuilder(ITypeSymbol type, WellKnownType return null; } - // Check that the type argument is a concrete type, not a type parameter - if (namedType.TypeArguments.Length == 1 && namedType.TypeArguments[0] is not ITypeParameterSymbol) + // Check that the type argument is a concrete resource type, not a type parameter or interface. + if (namedType.TypeArguments.Length == 1 && + namedType.TypeArguments[0] is not ITypeParameterSymbol && + namedType.TypeArguments[0].TypeKind is not TypeKind.Interface) { return namedType.TypeArguments[0].Name; } @@ -548,17 +568,19 @@ private static bool IsBuilderType(ITypeSymbol type, WellKnownTypes wellKnownType private static bool RequiresExplicitExportCoverage( ITypeSymbol type, WellKnownTypes wellKnownTypes, - INamedTypeSymbol aspireExportAttribute) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { return IsBuilderType(type, wellKnownTypes) || IsResourceType(type, wellKnownTypes) || - HasAspireExportAttribute(type, aspireExportAttribute); + HasAspireExportAttribute(type, aspireExportAttribute, currentAssemblyExportedTypes); } private static string? GetIncompatibilityReason( IMethodSymbol method, WellKnownTypes wellKnownTypes, - INamedTypeSymbol aspireExportAttribute) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { var reasons = new List(); @@ -611,7 +633,7 @@ private static bool RequiresExplicitExportCoverage( // Check delegate types more carefully if (IsDelegateType(paramType)) { - var reason = GetDelegateIncompatibilityReason(param, paramType, wellKnownTypes, aspireExportAttribute); + var reason = GetDelegateIncompatibilityReason(param, paramType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); if (reason is not null) { reasons.Add(reason); @@ -619,14 +641,14 @@ private static bool RequiresExplicitExportCoverage( continue; } - if (!IsAtsCompatibleValueType(paramType, wellKnownTypes, aspireExportAttribute)) + if (!IsAtsCompatibleValueType(paramType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { reasons.Add($"parameter '{param.Name}' of type '{paramType.ToDisplayString()}' is not ATS-compatible"); } } // Check return type - if (!IsAtsCompatibleType(method.ReturnType, wellKnownTypes, aspireExportAttribute)) + if (!IsAtsCompatibleType(method.ReturnType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { reasons.Add($"return type '{method.ReturnType.ToDisplayString()}' is not ATS-compatible"); } @@ -643,7 +665,8 @@ private static bool RequiresExplicitExportCoverage( IParameterSymbol param, ITypeSymbol delegateType, WellKnownTypes wellKnownTypes, - INamedTypeSymbol _) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { if (delegateType is not INamedTypeSymbol namedDelegate) { @@ -661,13 +684,7 @@ private static bool RequiresExplicitExportCoverage( foreach (var delegateParam in invokeMethod.Parameters) { var dpType = delegateParam.Type; - var dpTypeName = dpType.ToDisplayString(); - - // Check for known incompatible context types - if (dpTypeName is "System.IServiceProvider" or - "System.Text.Json.Utf8JsonWriter" or - "System.Threading.CancellationToken" or - "System.Net.Http.HttpRequestMessage") + if (!IsAtsCompatibleValueType(dpType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { return $"parameter '{param.Name}' uses delegate with '{dpType.Name}' which is not ATS-compatible"; } @@ -700,7 +717,8 @@ private static void AnalyzeUnionAttribute( ImmutableArray attributes, INamedTypeSymbol aspireUnionAttribute, WellKnownTypes wellKnownTypes, - INamedTypeSymbol aspireExportAttribute) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { foreach (var attr in attributes) { @@ -745,7 +763,7 @@ private static void AnalyzeUnionAttribute( { if (typeConstant.Value is INamedTypeSymbol typeSymbol) { - if (!IsAtsCompatibleValueType(typeSymbol, wellKnownTypes, aspireExportAttribute)) + if (!IsAtsCompatibleValueType(typeSymbol, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { context.ReportDiagnostic(Diagnostic.Create( Diagnostics.s_unionTypeMustBeAtsCompatible, @@ -853,7 +871,8 @@ private static bool IsRunSyncOnBackgroundThreadEnabled(AttributeData? exportAttr private static bool IsAtsCompatibleType( ITypeSymbol type, WellKnownTypes wellKnownTypes, - INamedTypeSymbol aspireExportAttribute) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { // void is allowed if (type.SpecialType == SpecialType.System_Void) @@ -861,21 +880,22 @@ private static bool IsAtsCompatibleType( return true; } - // Task and Task are allowed (for async methods) - if (IsTaskType(type, wellKnownTypes, aspireExportAttribute)) + // Task, Task, ValueTask, and ValueTask are allowed (for async methods) + if (IsAsyncResultType(type, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { return true; } - return IsAtsCompatibleValueType(type, wellKnownTypes, aspireExportAttribute); + return IsAtsCompatibleValueType(type, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } - private static bool IsTaskType( + private static bool IsAsyncResultType( ITypeSymbol type, WellKnownTypes wellKnownTypes, - INamedTypeSymbol aspireExportAttribute) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { - // Check for Task + // Check for Task / ValueTask try { var taskType = wellKnownTypes.Get(WellKnownTypeData.WellKnownType.System_Threading_Tasks_Task); @@ -889,7 +909,20 @@ private static bool IsTaskType( // Type not found } - // Check for Task + try + { + var valueTaskType = wellKnownTypes.Get(WellKnownTypeData.WellKnownType.System_Threading_Tasks_ValueTask); + if (SymbolEqualityComparer.Default.Equals(type, valueTaskType)) + { + return true; + } + } + catch (InvalidOperationException) + { + // Type not found + } + + // Check for Task / ValueTask if (type is INamedTypeSymbol namedType && namedType.IsGenericType) { try @@ -899,7 +932,21 @@ private static bool IsTaskType( { // Validate the T in Task is also ATS-compatible return namedType.TypeArguments.Length == 1 && - IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute); + IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); + } + } + catch (InvalidOperationException) + { + // Type not found + } + + try + { + var valueTaskOfTType = wellKnownTypes.Get(WellKnownTypeData.WellKnownType.System_Threading_Tasks_ValueTask_1); + if (SymbolEqualityComparer.Default.Equals(namedType.OriginalDefinition, valueTaskOfTType)) + { + return namedType.TypeArguments.Length == 1 && + IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } } catch (InvalidOperationException) @@ -914,7 +961,8 @@ private static bool IsTaskType( private static bool IsAtsCompatibleValueType( ITypeSymbol type, WellKnownTypes wellKnownTypes, - INamedTypeSymbol? aspireExportAttribute = null) + INamedTypeSymbol? aspireExportAttribute = null, + HashSet? currentAssemblyExportedTypes = null) { // Handle nullable types if (type is INamedTypeSymbol namedType && @@ -939,11 +987,11 @@ private static bool IsAtsCompatibleValueType( // Arrays of ATS-compatible types if (type is IArrayTypeSymbol arrayType) { - return IsAtsCompatibleValueType(arrayType.ElementType, wellKnownTypes, aspireExportAttribute); + return IsAtsCompatibleValueType(arrayType.ElementType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } // Collection types (Dictionary, List, IReadOnlyList, etc.) - if (IsAtsCompatibleCollectionType(type, wellKnownTypes, aspireExportAttribute)) + if (IsAtsCompatibleCollectionType(type, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes)) { return true; } @@ -961,7 +1009,7 @@ private static bool IsAtsCompatibleValueType( } // Types with [AspireExport] or [AspireDto] attribute - if (aspireExportAttribute != null && HasAspireExportAttribute(type, aspireExportAttribute)) + if (aspireExportAttribute != null && HasAspireExportAttribute(type, aspireExportAttribute, currentAssemblyExportedTypes)) { return true; } @@ -1063,7 +1111,8 @@ private static bool TryMatchGenericType(ITypeSymbol type, WellKnownTypes wellKno private static bool IsAtsCompatibleCollectionType( ITypeSymbol type, WellKnownTypes wellKnownTypes, - INamedTypeSymbol? aspireExportAttribute) + INamedTypeSymbol? aspireExportAttribute, + HashSet? currentAssemblyExportedTypes) { if (type is not INamedTypeSymbol namedType || !namedType.IsGenericType) { @@ -1076,8 +1125,8 @@ private static bool IsAtsCompatibleCollectionType( { // Validate key and value types are ATS-compatible return namedType.TypeArguments.Length == 2 && - IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute) && - IsAtsCompatibleValueType(namedType.TypeArguments[1], wellKnownTypes, aspireExportAttribute); + IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes) && + IsAtsCompatibleValueType(namedType.TypeArguments[1], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } // List and IList @@ -1085,7 +1134,7 @@ private static bool IsAtsCompatibleCollectionType( TryMatchGenericType(type, wellKnownTypes, WellKnownTypeData.WellKnownType.System_Collections_Generic_IList_1)) { return namedType.TypeArguments.Length == 1 && - IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute); + IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } // IReadOnlyList and IReadOnlyCollection @@ -1094,21 +1143,21 @@ private static bool IsAtsCompatibleCollectionType( TryMatchGenericType(type, wellKnownTypes, WellKnownTypeData.WellKnownType.System_Collections_Generic_IEnumerable_1)) { return namedType.TypeArguments.Length == 1 && - IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute); + IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } // IReadOnlyDictionary if (TryMatchGenericType(type, wellKnownTypes, WellKnownTypeData.WellKnownType.System_Collections_Generic_IReadOnlyDictionary_2)) { return namedType.TypeArguments.Length == 2 && - IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute) && - IsAtsCompatibleValueType(namedType.TypeArguments[1], wellKnownTypes, aspireExportAttribute); + IsAtsCompatibleValueType(namedType.TypeArguments[0], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes) && + IsAtsCompatibleValueType(namedType.TypeArguments[1], wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } return false; } - private static bool HasAspireExportAttribute(ITypeSymbol type, INamedTypeSymbol aspireExportAttribute) + private static bool HasAspireExportAttribute(ITypeSymbol type, INamedTypeSymbol aspireExportAttribute, HashSet? currentAssemblyExportedTypes) { // Check direct attributes on the type foreach (var attr in type.GetAttributes()) @@ -1119,6 +1168,11 @@ private static bool HasAspireExportAttribute(ITypeSymbol type, INamedTypeSymbol } } + if (currentAssemblyExportedTypes?.Contains(type) == true) + { + return true; + } + var containingAssembly = type.ContainingAssembly; if (containingAssembly is null) { @@ -1142,6 +1196,26 @@ private static bool HasAspireExportAttribute(ITypeSymbol type, INamedTypeSymbol return false; } + private static HashSet GetAssemblyExportedTypes(IAssemblySymbol assembly, INamedTypeSymbol aspireExportAttribute) + { + var exportedTypes = new HashSet(SymbolEqualityComparer.Default); + + foreach (var attr in assembly.GetAttributes()) + { + if (!SymbolEqualityComparer.Default.Equals(attr.AttributeClass, aspireExportAttribute)) + { + continue; + } + + if (TryGetAssemblyExportedType(attr, out var exportedType) && exportedType is not null) + { + exportedTypes.Add(exportedType); + } + } + + return exportedTypes; + } + private static bool TryGetAssemblyExportedType(AttributeData attribute, out ITypeSymbol? exportedType) { exportedType = null; @@ -1234,7 +1308,8 @@ private static bool IsResourceBuilderType(ITypeSymbol type, WellKnownTypes wellK private static bool IsAtsCompatibleParameter( IParameterSymbol parameter, WellKnownTypes wellKnownTypes, - INamedTypeSymbol aspireExportAttribute) + INamedTypeSymbol aspireExportAttribute, + HashSet currentAssemblyExportedTypes) { var type = parameter.Type; @@ -1247,10 +1322,10 @@ private static bool IsAtsCompatibleParameter( // params arrays are allowed if element type is compatible if (parameter.IsParams && type is IArrayTypeSymbol arrayType) { - return IsAtsCompatibleValueType(arrayType.ElementType, wellKnownTypes, aspireExportAttribute); + return IsAtsCompatibleValueType(arrayType.ElementType, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } - return IsAtsCompatibleValueType(type, wellKnownTypes, aspireExportAttribute); + return IsAtsCompatibleValueType(type, wellKnownTypes, aspireExportAttribute, currentAssemblyExportedTypes); } private static bool IsDelegateType(ITypeSymbol type) diff --git a/src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs b/src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs index 842446b6ea0..cc219f7e2fd 100644 --- a/src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs +++ b/src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs @@ -2538,7 +2538,8 @@ private static bool HasExposeMethodsAttribute(Type type) /// private static bool HasExportIgnoreAttribute(PropertyInfo property) { - return AttributeDataReader.HasAspireExportIgnoreData(property); + return AttributeDataReader.HasAspireExportIgnoreData(property) || + (property.DeclaringType is not null && AttributeDataReader.HasAspireExportIgnoreData(property.DeclaringType)); } /// @@ -2546,7 +2547,8 @@ private static bool HasExportIgnoreAttribute(PropertyInfo property) /// private static bool HasExportIgnoreAttribute(MethodInfo method) { - return AttributeDataReader.HasAspireExportIgnoreData(method); + return AttributeDataReader.HasAspireExportIgnoreData(method) || + (method.DeclaringType is not null && AttributeDataReader.HasAspireExportIgnoreData(method.DeclaringType)); } /// diff --git a/src/Aspire.Hosting/ApplicationModel/DistributedApplicationModelExtensions.cs b/src/Aspire.Hosting/ApplicationModel/DistributedApplicationModelExtensions.cs index e72f7464d3d..f355627bc81 100644 --- a/src/Aspire.Hosting/ApplicationModel/DistributedApplicationModelExtensions.cs +++ b/src/Aspire.Hosting/ApplicationModel/DistributedApplicationModelExtensions.cs @@ -14,6 +14,7 @@ public static class DistributedApplicationModelExtensions /// /// The distributed application model to extract compute resources from. /// An enumerable of compute in the model. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static IEnumerable GetComputeResources(this DistributedApplicationModel model) { foreach (var r in model.Resources) @@ -43,6 +44,7 @@ public static IEnumerable GetComputeResources(this DistributedApplica /// /// The distributed application model to extract build resources from. /// An enumerable of build in the model. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static IEnumerable GetBuildResources(this DistributedApplicationModel model) { foreach (var r in model.Resources) @@ -60,6 +62,7 @@ public static IEnumerable GetBuildResources(this DistributedApplicati /// /// The distributed application model to extract build and push resources from. /// An enumerable of build and push in the model. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static IEnumerable GetBuildAndPushResources(this DistributedApplicationModel model) { foreach (var r in model.Resources) diff --git a/src/Aspire.Hosting/ApplicationModel/ProjectResourceExtensions.cs b/src/Aspire.Hosting/ApplicationModel/ProjectResourceExtensions.cs index 8ce815484eb..27b79fabf6e 100644 --- a/src/Aspire.Hosting/ApplicationModel/ProjectResourceExtensions.cs +++ b/src/Aspire.Hosting/ApplicationModel/ProjectResourceExtensions.cs @@ -13,6 +13,7 @@ public static class ProjectResourceExtensions /// /// The distributed application model. /// An enumerable collection of project resources. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static IEnumerable GetProjectResources(this DistributedApplicationModel model) { ArgumentNullException.ThrowIfNull(model); @@ -26,6 +27,7 @@ public static IEnumerable GetProjectResources(this DistributedA /// The project resource. /// The project metadata. /// Thrown when the project resource doesn't have project metadata. + [AspireExportIgnore(Reason = "Project metadata is a .NET-specific contract and is not part of the ATS surface.")] public static IProjectMetadata GetProjectMetadata(this ProjectResource projectResource) { ArgumentNullException.ThrowIfNull(projectResource); diff --git a/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs b/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs index 103e44dd71d..a08f003132f 100644 --- a/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs +++ b/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs @@ -24,6 +24,7 @@ public static class ResourceExtensions /// The resource to get the annotation from. /// When this method returns, contains the last annotation of the specified type from the resource, if found; otherwise, the default value for . /// if the last annotation of the specified type was found in the resource; otherwise, . + [AspireExportIgnore(Reason = "Generic annotation inspection helper — not part of the ATS surface.")] public static bool TryGetLastAnnotation(this IResource resource, [NotNullWhen(true)] out T? annotation) where T : IResourceAnnotation { if (resource.Annotations.OfType().LastOrDefault() is { } lastAnnotation) @@ -45,6 +46,7 @@ public static bool TryGetLastAnnotation(this IResource resource, [NotNullWhen /// The resource to retrieve annotations from. /// When this method returns, contains the annotations of the specified type, if found; otherwise, . /// if annotations of the specified type were found; otherwise, . + [AspireExportIgnore(Reason = "Generic annotation inspection helper — not part of the ATS surface.")] public static bool TryGetAnnotationsOfType(this IResource resource, [NotNullWhen(true)] out IEnumerable? result) where T : IResourceAnnotation { var matchingTypeAnnotations = resource.Annotations.OfType(); @@ -67,6 +69,7 @@ public static bool TryGetAnnotationsOfType(this IResource resource, [NotNullW /// The type of annotation to retrieve. /// The resource to retrieve annotations from. /// if an annotation of the specified type was found; otherwise, . + [AspireExportIgnore(Reason = "Generic annotation inspection helper — not part of the ATS surface.")] public static bool HasAnnotationOfType(this IResource resource) where T : IResourceAnnotation { return resource.Annotations.Any(a => a is T); @@ -79,6 +82,7 @@ public static bool HasAnnotationOfType(this IResource resource) where T : IRe /// The resource to retrieve annotations from. /// When this method returns, contains the annotations of the specified type, if found; otherwise, . /// if annotations of the specified type were found; otherwise, . + [AspireExportIgnore(Reason = "Generic annotation inspection helper — not part of the ATS surface.")] public static bool TryGetAnnotationsIncludingAncestorsOfType(this IResource resource, [NotNullWhen(true)] out IEnumerable? result) where T : IResourceAnnotation { if (resource is IResourceWithParent) @@ -116,6 +120,7 @@ public static bool TryGetAnnotationsIncludingAncestorsOfType(this IResource r /// The type of annotation to retrieve. /// The resource to retrieve annotations from. /// if an annotation of the specified type was found; otherwise, . + [AspireExportIgnore(Reason = "Generic annotation inspection helper — not part of the ATS surface.")] public static bool HasAnnotationIncludingAncestorsOfType(this IResource resource) where T : IResourceAnnotation { if (resource is IResourceWithParent) @@ -149,6 +154,7 @@ public static bool HasAnnotationIncludingAncestorsOfType(this IResource resou /// The resource to get the environment variables from. /// The environment variables retrieved from the resource, if any. /// True if the environment variables were successfully retrieved, false otherwise. + [AspireExportIgnore(Reason = "Environment callback inspection helper — not part of the ATS surface.")] public static bool TryGetEnvironmentVariables(this IResource resource, [NotNullWhen(true)] out IEnumerable? environmentVariables) { return TryGetAnnotationsOfType(resource, out environmentVariables); @@ -545,6 +551,7 @@ internal static IEnumerable GetSupportedNetworks(this IResour /// Gets a value indicating whether the resource is excluded from being published. /// /// The resource to determine if it should be excluded from being published. + [AspireExportIgnore(Reason = "Manifest inspection helper — not part of the ATS surface.")] public static bool IsExcludedFromPublish(this IResource resource) => resource.TryGetLastAnnotation(out var lastAnnotation) && lastAnnotation == ManifestPublishingCallbackAnnotation.Ignore; @@ -635,6 +642,7 @@ internal static async ValueTask ProcessContainerRuntimeArgValues( /// The resource to get the volume mounts for. /// When this method returns, contains the volume mounts for the specified resource, if found; otherwise, null. /// true if the volume mounts were successfully retrieved; otherwise, false. + [AspireExportIgnore(Reason = "Container mount inspection helper — not part of the ATS surface.")] public static bool TryGetContainerMounts(this IResource resource, [NotNullWhen(true)] out IEnumerable? volumeMounts) { return TryGetAnnotationsOfType(resource, out volumeMounts); @@ -646,6 +654,7 @@ public static bool TryGetContainerMounts(this IResource resource, [NotNullWhen(t /// The resource to retrieve the endpoints for. /// The endpoints for the given resource, if found. /// True if the endpoints were found, false otherwise. + [AspireExportIgnore(Reason = "Endpoint annotation inspection helper — not part of the ATS surface.")] public static bool TryGetEndpoints(this IResource resource, [NotNullWhen(true)] out IEnumerable? endpoints) { return TryGetAnnotationsOfType(resource, out endpoints); @@ -657,6 +666,7 @@ public static bool TryGetEndpoints(this IResource resource, [NotNullWhen(true)] /// The resource to retrieve the URLs for. /// The URLs for the given resource, if found. /// True if the URLs were found, false otherwise. + [AspireExportIgnore(Reason = "URL annotation inspection helper — not part of the ATS surface.")] public static bool TryGetUrls(this IResource resource, [NotNullWhen(true)] out IEnumerable? urls) { return TryGetAnnotationsOfType(resource, out urls); @@ -667,6 +677,7 @@ public static bool TryGetUrls(this IResource resource, [NotNullWhen(true)] out I /// /// The which contains annotations. /// An enumeration of based on the annotations from the resources' collection. + [AspireExportIgnore(Reason = "Resource handle endpoint enumeration is not part of the ATS surface; use builder-based endpoint exports instead.")] public static IEnumerable GetEndpoints(this IResourceWithEndpoints resource) { if (TryGetAnnotationsOfType(resource, out var endpoints)) @@ -683,6 +694,7 @@ public static IEnumerable GetEndpoints(this IResourceWithEndp /// The which contains annotations. /// The ID of the network that serves as the context context for the endpoint references. /// An enumeration of based on the annotations from the resources' collection. + [AspireExportIgnore(Reason = "Network-specific endpoint enumeration is not part of the ATS surface.")] public static IEnumerable GetEndpoints(this IResourceWithEndpoints resource, NetworkIdentifier contextNetworkID) { if (TryGetAnnotationsOfType(resource, out var endpoints)) @@ -699,6 +711,7 @@ public static IEnumerable GetEndpoints(this IResourceWithEndp /// The which contains annotations. /// The name of the endpoint. /// An object providing resolvable reference for the specified endpoint. + [AspireExportIgnore(Reason = "Resource handle endpoint lookup is not part of the ATS surface; use builder-based endpoint exports instead.")] public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource, string endpointName) { var endpoint = resource.TryGetEndpoints(out var endpoints) ? @@ -721,6 +734,7 @@ public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource /// The name of the endpoint. /// The network ID of the network that provides the context for the returned /// An object providing resolvable reference for the specified endpoint. + [AspireExportIgnore(Reason = "Network-specific endpoint lookup is not part of the ATS surface.")] public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource, string endpointName, NetworkIdentifier contextNetworkID) { @@ -745,6 +759,7 @@ public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource /// The resource containing endpoints to resolve. /// Optional port allocator. If null, uses default allocation starting from port 8000. /// A read-only list of resolved endpoints with computed port values. + [AspireExportIgnore(Reason = "Endpoint resolution exposes infrastructure-specific types that are not part of the ATS surface.")] public static IReadOnlyList ResolveEndpoints(this IResource resource, IPortAllocator? portAllocator = null) { if (!resource.TryGetEndpoints(out var endpoints)) @@ -828,6 +843,7 @@ public static IReadOnlyList ResolveEndpoints(this IResource re /// The resource to get the container image name from. /// The container image name if found, otherwise null. /// True if the container image name was found, otherwise false. + [AspireExportIgnore(Reason = "Container image inspection helper — not part of the ATS surface.")] public static bool TryGetContainerImageName(this IResource resource, [NotNullWhen(true)] out string? imageName) { return TryGetContainerImageName(resource, useBuiltImage: true, out imageName); @@ -840,6 +856,7 @@ public static bool TryGetContainerImageName(this IResource resource, [NotNullWhe /// When true, uses the image name from DockerfileBuildAnnotation if present. When false, uses only ContainerImageAnnotation. /// The container image name if found, otherwise null. /// True if the container image name was found, otherwise false. + [AspireExportIgnore(Reason = "Container image inspection helper — not part of the ATS surface.")] public static bool TryGetContainerImageName(this IResource resource, bool useBuiltImage, [NotNullWhen(true)] out string? imageName) { // First check if there's a DockerfileBuildAnnotation with an image name/tag @@ -881,6 +898,7 @@ public static bool TryGetContainerImageName(this IResource resource, bool useBui /// /// The resource to get the replica count for. /// The number of replicas for the specified resource. + [AspireExportIgnore(Reason = "Replica inspection helper — not part of the ATS surface.")] public static int GetReplicaCount(this IResource resource) { if (resource.TryGetLastAnnotation(out var replicaAnnotation)) @@ -902,6 +920,7 @@ public static int GetReplicaCount(this IResource resource) /// /// The resource to evaluate for image build requirements. /// True if the resource requires image building; otherwise, false. + [AspireExportIgnore(Reason = "Publishing inspection helper — not part of the ATS surface.")] public static bool RequiresImageBuild(this IResource resource) { if (resource.IsExcludedFromPublish()) @@ -922,6 +941,7 @@ public static bool RequiresImageBuild(this IResource resource) /// /// The resource to evaluate for image push requirements. /// True if the resource requires image building and pushing; otherwise, false. + [AspireExportIgnore(Reason = "Publishing inspection helper — not part of the ATS surface.")] public static bool RequiresImageBuildAndPush(this IResource resource) { return resource.RequiresImageBuild() && !resource.IsBuildOnlyContainer(); @@ -938,6 +958,7 @@ internal static bool IsBuildOnlyContainer(this IResource resource) /// /// The resource to get the compute environment for. /// The compute environment the resource is bound to, or null if the resource is not bound to any specific compute environment. + [AspireExportIgnore(Reason = "Compute-environment inspection helper — not part of the ATS surface.")] public static IComputeEnvironmentResource? GetComputeEnvironment(this IResource resource) { if (resource.TryGetLastAnnotation(out var computeEnvironmentAnnotation)) @@ -951,6 +972,7 @@ internal static bool IsBuildOnlyContainer(this IResource resource) /// Gets the deployment target for the specified resource, if any. Throws an exception if /// there are multiple compute environments and a compute environment is not explicitly specified. /// + [AspireExportIgnore(Reason = "Deployment target inspection helper — not part of the ATS surface.")] public static DeploymentTargetAnnotation? GetDeploymentTargetAnnotation(this IResource resource, IComputeEnvironmentResource? targetComputeEnvironment = null) { IComputeEnvironmentResource? selectedComputeEnvironment = null; @@ -1258,6 +1280,7 @@ internal static ILogger GetLogger(this IResource resource, IServiceProvider serv /// This method invokes environment variable and command-line argument callbacks to discover all references. The context resource () is not considered a dependency (even if it is transitively referenced). /// /// + [AspireExportIgnore(Reason = "Dependency discovery helper depends on execution context and is not part of the ATS surface.")] public static async Task> GetResourceDependenciesAsync( this IResource resource, DistributedApplicationExecutionContext executionContext, diff --git a/src/Aspire.Hosting/Aspire.Hosting.csproj b/src/Aspire.Hosting/Aspire.Hosting.csproj index 56a23e14516..0e720063c1a 100644 --- a/src/Aspire.Hosting/Aspire.Hosting.csproj +++ b/src/Aspire.Hosting/Aspire.Hosting.csproj @@ -130,11 +130,6 @@ - - - - - $(BeforePack);IncludeIntegrationAnalyzerInPackage diff --git a/src/Aspire.Hosting/Ats/AspireExportIgnoreAttribute.cs b/src/Aspire.Hosting/Ats/AspireExportIgnoreAttribute.cs index fc6c4662bb6..67927023ea6 100644 --- a/src/Aspire.Hosting/Ats/AspireExportIgnoreAttribute.cs +++ b/src/Aspire.Hosting/Ats/AspireExportIgnoreAttribute.cs @@ -6,7 +6,7 @@ namespace Aspire.Hosting; /// -/// Excludes a property or method from ATS export when the containing type uses +/// Excludes a property, method, or type from ATS export when the containing type uses /// or . /// /// @@ -18,6 +18,10 @@ namespace Aspire.Hosting; /// This is useful when most members should be exposed but a few contain internal /// implementation details or types that shouldn't be part of the polyglot API. /// +/// +/// Apply this attribute to a type to suppress all automatic export coverage checks for the +/// type's members when the type is intentionally not part of the ATS surface. +/// /// /// /// @@ -33,7 +37,7 @@ namespace Aspire.Hosting; /// /// [AttributeUsage( - AttributeTargets.Property | AttributeTargets.Method, + AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Method, Inherited = false, AllowMultiple = false)] [Experimental("ASPIREATS001")] diff --git a/src/Aspire.Hosting/ConnectionPropertiesExtensions.cs b/src/Aspire.Hosting/ConnectionPropertiesExtensions.cs index ba0659d568d..fe3e7193891 100644 --- a/src/Aspire.Hosting/ConnectionPropertiesExtensions.cs +++ b/src/Aspire.Hosting/ConnectionPropertiesExtensions.cs @@ -16,6 +16,7 @@ public static class ConnectionPropertiesExtensions /// The resource that exposes the base connection properties. /// The additional connection properties to merge into the values supplied by . /// A sequence that contains the combined set of connection properties with duplicate keys resolved in favor of . + [AspireExportIgnore(Reason = "Connection property merging is an internal helper and is not part of the ATS surface.")] public static IEnumerable> CombineProperties(this IResourceWithConnectionString source, IEnumerable> additional) { ArgumentNullException.ThrowIfNull(source); @@ -35,4 +36,4 @@ public static IEnumerable> CombineProp return dict.AsEnumerable(); } -} \ No newline at end of file +} diff --git a/src/Aspire.Hosting/ConnectionStringBuilderExtensions.cs b/src/Aspire.Hosting/ConnectionStringBuilderExtensions.cs index 05975ad903f..2e53ac75db5 100644 --- a/src/Aspire.Hosting/ConnectionStringBuilderExtensions.cs +++ b/src/Aspire.Hosting/ConnectionStringBuilderExtensions.cs @@ -142,7 +142,7 @@ await evt.Notifications.PublishUpdateAsync(r, s => s with /// builder.Build().Run(); /// /// - [AspireExport("addConnectionStringBuilder", Description = "Adds a connection string with a builder callback")] + [AspireExport("addConnectionStringBuilder", Description = "Adds a connection string with a builder callback", RunSyncOnBackgroundThread = true)] public static IResourceBuilder AddConnectionString(this IDistributedApplicationBuilder builder, [ResourceName] string name, Action connectionStringBuilder) { var rb = new ReferenceExpressionBuilder(); diff --git a/src/Aspire.Hosting/ContainerExecutableResourceExtensions.cs b/src/Aspire.Hosting/ContainerExecutableResourceExtensions.cs index c58cdf75d9f..b182c0faeae 100644 --- a/src/Aspire.Hosting/ContainerExecutableResourceExtensions.cs +++ b/src/Aspire.Hosting/ContainerExecutableResourceExtensions.cs @@ -15,6 +15,7 @@ internal static class ContainerExecutableResourceExtensions /// /// The distributed application model to retrieve executable resources from. /// An enumerable collection of executable resources. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static IEnumerable GetContainerExecutableResources(this DistributedApplicationModel model) { ArgumentNullException.ThrowIfNull(model); diff --git a/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs b/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs index 54b059c81c1..d97965c4419 100644 --- a/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs @@ -1091,7 +1091,7 @@ public static IResourceBuilder WithBuildArg(this IResourceBuilder build /// /// /// - [AspireExport("withBuildArg", Description = "Adds a build argument from a parameter resource")] + [AspireExport("withParameterBuildArg", MethodName = "withBuildArg", Description = "Adds a build argument from a parameter resource")] public static IResourceBuilder WithBuildArg(this IResourceBuilder builder, string name, IResourceBuilder value) where T : ContainerResource { ArgumentNullException.ThrowIfNull(builder); @@ -1139,7 +1139,7 @@ public static IResourceBuilder WithBuildArg(this IResourceBuilder build /// /// /// - [AspireExport("withBuildSecret", Description = "Adds a build secret from a parameter resource")] + [AspireExport("withParameterBuildSecret", MethodName = "withBuildSecret", Description = "Adds a build secret from a parameter resource")] public static IResourceBuilder WithBuildSecret(this IResourceBuilder builder, string name, IResourceBuilder value) where T : ContainerResource { ArgumentNullException.ThrowIfNull(builder); diff --git a/src/Aspire.Hosting/ContainerResourceExtensions.cs b/src/Aspire.Hosting/ContainerResourceExtensions.cs index ea48e0b5575..79ea9e54bfc 100644 --- a/src/Aspire.Hosting/ContainerResourceExtensions.cs +++ b/src/Aspire.Hosting/ContainerResourceExtensions.cs @@ -15,6 +15,7 @@ public static class ContainerResourceExtensions /// /// The distributed application model to search for container resources. /// A collection of container resources in the specified distributed application model. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static IEnumerable GetContainerResources(this DistributedApplicationModel model) { ArgumentNullException.ThrowIfNull(model); @@ -33,6 +34,7 @@ public static IEnumerable GetContainerResources(this DistributedAppli /// /// The resource to check. /// true if the specified resource is a container resource; otherwise, false. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static bool IsContainer(this IResource resource) { ArgumentNullException.ThrowIfNull(resource); diff --git a/src/Aspire.Hosting/EmulatorResourceExtensions.cs b/src/Aspire.Hosting/EmulatorResourceExtensions.cs index b6199786714..28f04454833 100644 --- a/src/Aspire.Hosting/EmulatorResourceExtensions.cs +++ b/src/Aspire.Hosting/EmulatorResourceExtensions.cs @@ -15,6 +15,7 @@ public static class EmulatorResourceExtensions /// /// The resource to check. /// true if the specified resource is an emulator resource; otherwise, false. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static bool IsEmulator(this IResource resource) { ArgumentNullException.ThrowIfNull(resource); diff --git a/src/Aspire.Hosting/ExecutableResourceBuilderExtensions.cs b/src/Aspire.Hosting/ExecutableResourceBuilderExtensions.cs index 53c28d1174b..8a87eda8c17 100644 --- a/src/Aspire.Hosting/ExecutableResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ExecutableResourceBuilderExtensions.cs @@ -117,7 +117,7 @@ public static IResourceBuilder PublishAsDockerFile(this IResourceBuilderResource builder /// Optional action to configure the container resource /// A reference to the . - [AspireExport("publishAsDockerFileWithConfigure", Description = "Publishes an executable as a Docker file with optional container configuration")] + [AspireExport("publishAsDockerFileWithConfigure", Description = "Publishes an executable as a Docker file with optional container configuration", RunSyncOnBackgroundThread = true)] public static IResourceBuilder PublishAsDockerFile(this IResourceBuilder builder, Action>? configure) where T : ExecutableResource { diff --git a/src/Aspire.Hosting/ExecutableResourceExtensions.cs b/src/Aspire.Hosting/ExecutableResourceExtensions.cs index 69fccd1f39a..3f9766081a8 100644 --- a/src/Aspire.Hosting/ExecutableResourceExtensions.cs +++ b/src/Aspire.Hosting/ExecutableResourceExtensions.cs @@ -15,6 +15,7 @@ public static class ExecutableResourceExtensions /// /// The distributed application model to retrieve executable resources from. /// An enumerable collection of executable resources. + [AspireExportIgnore(Reason = "Application model inspection helper — not part of the ATS surface.")] public static IEnumerable GetExecutableResources(this DistributedApplicationModel model) { ArgumentNullException.ThrowIfNull(model); diff --git a/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs b/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs index 4428de7c977..a8d0ee6c746 100644 --- a/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs @@ -282,7 +282,7 @@ public static IResourceBuilder AddProject(this IDistributedAppl /// /// /// - [AspireExport("addProjectWithOptions", Description = "Adds a project resource with configuration options")] + [AspireExport("addProjectWithOptions", Description = "Adds a project resource with configuration options", RunSyncOnBackgroundThread = true)] public static IResourceBuilder AddProject(this IDistributedApplicationBuilder builder, [ResourceName] string name, string projectPath, Action configure) { ArgumentNullException.ThrowIfNull(builder); @@ -364,7 +364,7 @@ public static IResourceBuilder AddCSharpApp(this IDistributedAp /// /// [Experimental("ASPIRECSHARPAPPS001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] - [AspireExport("addCSharpAppWithOptions", Description = "Adds a C# application resource with configuration options")] + [AspireExport("addCSharpAppWithOptions", Description = "Adds a C# application resource with configuration options", RunSyncOnBackgroundThread = true)] public static IResourceBuilder AddCSharpApp(this IDistributedApplicationBuilder builder, [ResourceName] string name, string path, Action configure) { ArgumentNullException.ThrowIfNull(builder); @@ -826,7 +826,7 @@ public static IResourceBuilder WithEndpointsInEnvironment( /// Resource builder /// Optional action to configure the container resource /// A reference to the . - [AspireExport("publishProjectAsDockerFileWithConfigure", MethodName = "publishAsDockerFile", Description = "Publishes a project as a Docker file with optional container configuration")] + [AspireExport("publishProjectAsDockerFileWithConfigure", MethodName = "publishAsDockerFile", Description = "Publishes a project as a Docker file with optional container configuration", RunSyncOnBackgroundThread = true)] public static IResourceBuilder PublishAsDockerFile(this IResourceBuilder builder, Action>? configure = null) where T : ProjectResource { diff --git a/src/Aspire.Hosting/Publishing/PublishingExtensions.cs b/src/Aspire.Hosting/Publishing/PublishingExtensions.cs index 4bf20c4d1f9..31407b9c871 100644 --- a/src/Aspire.Hosting/Publishing/PublishingExtensions.cs +++ b/src/Aspire.Hosting/Publishing/PublishingExtensions.cs @@ -11,6 +11,7 @@ namespace Aspire.Hosting.Pipelines; /// Extension methods for and to provide direct operations. /// [Experimental("ASPIREPIPELINES001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] +[AspireExportIgnore(Reason = "Convenience wrapper over pipeline APIs — use the dedicated ATS pipeline exports instead.")] public static class PublishingExtensions { /// diff --git a/src/Aspire.Hosting/ResourceBuilderExtensions.cs b/src/Aspire.Hosting/ResourceBuilderExtensions.cs index d548b1a5edf..3ddd0825dd4 100644 --- a/src/Aspire.Hosting/ResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ResourceBuilderExtensions.cs @@ -761,6 +761,7 @@ private static void SplatConnectionProperties(IResourceWithConnectionString reso /// The resource that provides the connection properties. Cannot be null. /// The key of the connection property to retrieve. Cannot be null. /// The value associated with the specified connection property key. + [AspireExport("getConnectionProperty", Description = "Gets a connection property by key")] public static ReferenceExpression GetConnectionProperty(this IResourceWithConnectionString resource, string key) { foreach (var connectionProperty in resource.GetConnectionProperties()) @@ -1569,7 +1570,7 @@ public static IResourceBuilder WithUrlForEndpoint(this IResourceBuilder /// The resource builder to which container files will be copied to. /// The resource which contains the container files to be copied. /// The destination path within the resource's container where the files will be copied. - [AspireExport("publishWithContainerFiles", Description = "Configures the resource to copy container files from the specified source during publishing")] + [AspireExport("publishWithContainerFilesFromResource", MethodName = "publishWithContainerFiles", Description = "Configures the resource to copy container files from the specified source during publishing")] public static IResourceBuilder PublishWithContainerFiles( this IResourceBuilder builder, IResourceBuilder source, @@ -1674,7 +1675,7 @@ public static IResourceBuilder ExcludeFromManifest(this IResourceBuilder /// /// - [AspireExport("waitFor", Description = "Waits for another resource to be ready")] + [AspireExport("waitForResource", MethodName = "waitFor", Description = "Waits for another resource to be ready")] public static IResourceBuilder WaitFor(this IResourceBuilder builder, IResourceBuilder dependency) where T : IResourceWithWaitSupport { ArgumentNullException.ThrowIfNull(builder); @@ -1782,7 +1783,7 @@ private static IResourceBuilder WaitForCore(this IResourceBuilder build /// /// /// - [AspireExport("waitForStart", Description = "Waits for another resource to start")] + [AspireExport("waitForResourceStart", MethodName = "waitForStart", Description = "Waits for another resource to start")] public static IResourceBuilder WaitForStart(this IResourceBuilder builder, IResourceBuilder dependency) where T : IResourceWithWaitSupport { ArgumentNullException.ThrowIfNull(builder); @@ -1926,7 +1927,7 @@ public static IResourceBuilder WithExplicitStart(this IResourceBuilder /// /// /// - [AspireExport("waitForCompletion", Description = "Waits for resource completion")] + [AspireExport("waitForResourceCompletion", MethodName = "waitForCompletion", Description = "Waits for resource completion")] public static IResourceBuilder WaitForCompletion(this IResourceBuilder builder, IResourceBuilder dependency, int exitCode = 0) where T : IResourceWithWaitSupport { ArgumentNullException.ThrowIfNull(builder); @@ -2716,7 +2717,7 @@ public static IResourceBuilder WithCertificateTrustConfiguration /// [Experimental("ASPIRECERTIFICATES001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] - [AspireExport("withHttpsDeveloperCertificate", Description = "Configures HTTPS with a developer certificate")] + [AspireExport("withParameterHttpsDeveloperCertificate", MethodName = "withHttpsDeveloperCertificate", Description = "Configures HTTPS with a developer certificate")] public static IResourceBuilder WithHttpsDeveloperCertificate(this IResourceBuilder builder, IResourceBuilder? password = null) where TResource : IResourceWithEnvironment, IResourceWithArgs { @@ -3116,7 +3117,7 @@ public static IResourceBuilder WithReferenceRelationship( /// /// /// - [AspireExport("withParentRelationship", Description = "Sets the parent relationship")] + [AspireExport("withBuilderParentRelationship", MethodName = "withParentRelationship", Description = "Sets the parent relationship")] public static IResourceBuilder WithParentRelationship( this IResourceBuilder builder, IResourceBuilder parent) where T : IResource @@ -3180,7 +3181,7 @@ public static IResourceBuilder WithParentRelationship( /// /// /// - [AspireExport("withChildRelationship", Description = "Sets a child relationship")] + [AspireExport("withBuilderChildRelationship", MethodName = "withChildRelationship", Description = "Sets a child relationship")] public static IResourceBuilder WithChildRelationship( this IResourceBuilder builder, IResourceBuilder child) where T : IResource @@ -3289,6 +3290,7 @@ public static IResourceBuilder WithComputeEnvironment(this IResourceBuilde /// The type of the resource. /// Optional callback to add or modify command line arguments when running in an extension host. Useful if the entrypoint is usually provided as an argument to the resource executable. [Experimental("ASPIREEXTENSION001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] + [AspireExportIgnore(Reason = "Generic debug launch configuration support is not part of the ATS surface.")] public static IResourceBuilder WithDebugSupport(this IResourceBuilder builder, Func launchConfigurationProducer, string launchConfigurationType, Action? argsCallback = null) where T : IResource { @@ -3348,6 +3350,7 @@ public static IResourceBuilder WithDebugSupport(this /// This method is not available in polyglot app hosts. The parameter name 'type' is a reserved keyword in Go and Rust. /// [Experimental("ASPIREPROBES001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] + [AspireExportIgnore(Reason = "Use the ATS export stub with renamed probeType parameter instead.")] public static IResourceBuilder WithHttpProbe(this IResourceBuilder builder, ProbeType type, string? path = null, int? initialDelaySeconds = null, int? periodSeconds = null, int? timeoutSeconds = null, int? failureThreshold = null, int? successThreshold = null, string? endpointName = null) where T : IResourceWithEndpoints, IResourceWithProbes { diff --git a/src/Aspire.Hosting/Utils/ExtensionUtils.cs b/src/Aspire.Hosting/Utils/ExtensionUtils.cs index 62efc6b5f9e..27ea86fb712 100644 --- a/src/Aspire.Hosting/Utils/ExtensionUtils.cs +++ b/src/Aspire.Hosting/Utils/ExtensionUtils.cs @@ -13,6 +13,7 @@ namespace Aspire.Hosting.Utils; #pragma warning disable ASPIREEXTENSION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. internal static class ExtensionUtils { + [AspireExportIgnore(Reason = "Debug support inspection is a local .NET helper and is not part of the ATS surface.")] public static bool SupportsDebugging(this IResource builder, IConfiguration configuration, [NotNullWhen(true)] out SupportsDebuggingAnnotation? supportsDebuggingAnnotation) { var supportedLaunchConfigurations = GetSupportedLaunchConfigurations(configuration); diff --git a/src/Aspire.TypeSystem/AttributeDataReader.cs b/src/Aspire.TypeSystem/AttributeDataReader.cs index d3a83532c81..1019320056d 100644 --- a/src/Aspire.TypeSystem/AttributeDataReader.cs +++ b/src/Aspire.TypeSystem/AttributeDataReader.cs @@ -45,6 +45,12 @@ public static IEnumerable GetAspireExportDataAll(Assembly asse // --- AspireExportIgnore lookup --- + /// + /// Determines whether the specified has the AspireExportIgnore attribute. + /// + public static bool HasAspireExportIgnoreData(Type type) + => HasAttribute(type.GetCustomAttributesData(), AspireExportIgnoreAttributeFullName); + /// /// Determines whether the specified has the AspireExportIgnore attribute. /// diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 63c1108cf71..ff3b4ae7799 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -16,7 +16,7 @@ - (""" + using Aspire.Hosting; + + var builder = DistributedApplication.CreateBuilder(args); + + [AspireExport] + public class TestExports + { + [AspireExport("instanceMethod")] + public string InstanceMethod() => "test"; + } + """, []); + + await test.RunAsync(); + } + [Fact] public async Task InvalidIdFormat_WithSlash_ReportsASPIREEXPORT002() { @@ -228,6 +247,28 @@ public static class TestExports await test.RunAsync(); } + [Fact] + public async Task ValidValueTaskReturn_NoDiagnostics() + { + var test = AnalyzerTest.Create(""" + using Aspire.Hosting; + using System.Threading.Tasks; + + var builder = DistributedApplication.CreateBuilder(args); + + public static class TestExports + { + [AspireExport("asyncMethod")] + public static ValueTask AsyncMethod() => ValueTask.CompletedTask; + + [AspireExport("asyncMethodWithResult")] + public static ValueTask AsyncMethodWithResult() => ValueTask.FromResult("test"); + } + """, []); + + await test.RunAsync(); + } + [Fact] public async Task ValidEnumTypes_NoDiagnostics() { @@ -675,6 +716,48 @@ public static void Method(MyCustomType custom) { } await test.RunAsync(); } + [Fact] + public async Task AssemblyExportedExternalType_NoDiagnostics() + { + var test = AnalyzerTest.Create(""" + using System; + using Aspire.Hosting; + + [assembly: AspireExport(typeof(IServiceProvider))] + + var builder = DistributedApplication.CreateBuilder(args); + + public static class TestExports + { + [AspireExport("getProvider")] + public static IServiceProvider GetProvider(this IServiceProvider provider) => provider; + } + """, []); + + await test.RunAsync(); + } + + [Fact] + public async Task ArrayOfAssemblyExportedExternalType_NoDiagnostics() + { + var test = AnalyzerTest.Create(""" + using System; + using Aspire.Hosting; + + [assembly: AspireExport(typeof(IServiceProvider))] + + var builder = DistributedApplication.CreateBuilder(args); + + public static class TestExports + { + [AspireExport("getChildren")] + public static IServiceProvider[] GetChildren(IServiceProvider[] providers) => providers; + } + """, []); + + await test.RunAsync(); + } + [Fact] public async Task ValidObjectType_NoDiagnostics() { @@ -1282,6 +1365,24 @@ public static void AddThing(this IDistributedApplicationBuilder builder, string await test.RunAsync(); } + [Fact] + public async Task MissingExportAttribute_WithContainingTypeAspireExportIgnore_NoDiagnostics() + { + var test = AnalyzerTest.Create(""" + using Aspire.Hosting; + + var builder = DistributedApplication.CreateBuilder(args); + + [AspireExportIgnore(Reason = "Not part of the ATS surface.")] + public static class TestExtensions + { + public static void AddThing(this IDistributedApplicationBuilder builder, string name) { } + } + """, []); + + await test.RunAsync(); + } + [Fact] public async Task MissingExportAttribute_ObsoleteMethod_NoDiagnostics() { @@ -1386,6 +1487,29 @@ public static void Configure(this AssemblyExportedHandle handle) { } await test.RunAsync(); } + [Fact] + public async Task MissingExportAttribute_OnAssemblyExportedExternalTypeExtension_ReportsASPIREEXPORT008() + { + var diagnostic = AspireExportAnalyzer.Diagnostics.s_missingExportAttribute; + + var test = AnalyzerTest.Create(""" + using System; + using Aspire.Hosting; + + [assembly: AspireExport(typeof(IServiceProvider))] + + var builder = DistributedApplication.CreateBuilder(args); + + public static class TestExports + { + public static void Configure(this IServiceProvider serviceProvider) { } + } + """, + [new DiagnosticResult(diagnostic).WithLocation(10, 24).WithArguments("Configure", "Add [AspireExport] if ATS-compatible, or [AspireExportIgnore] with a reason.")]); + + await test.RunAsync(); + } + [Fact] public async Task MissingExportAttribute_OnImplicitlyExportedResourceTypeExtension_ReportsASPIREEXPORT008() { @@ -1534,6 +1658,29 @@ internal static IResourceBuilder WithEnvironment( await test.RunAsync(); } + [Fact] + public async Task ExportNameMatchesMethodName_WithInterfaceTarget_NoDiagnostics() + { + var test = AnalyzerTest.Create(""" + using Aspire.Hosting; + using Aspire.Hosting.ApplicationModel; + + var builder = DistributedApplication.CreateBuilder(args); + + public static class TestExports + { + [AspireExport("withReference")] + internal static IResourceBuilder WithReference( + this IResourceBuilder builder, + IResourceBuilder target) + where T : IResourceWithEnvironment + => builder; + } + """, []); + + await test.RunAsync(); + } + [Fact] public async Task ExportNameMatchesMethodName_ConcreteFirstParam_NoDiagnostics() { diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go index 7a9f7be1652..9c1b48f5d90 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go @@ -1001,7 +1001,7 @@ func (s *CSharpAppResource) PublishWithContainerFiles(source *IResourceWithConta } reqArgs["source"] = SerializeValue(source) reqArgs["destinationPath"] = SerializeValue(destinationPath) - result, err := s.Client().InvokeCapability("Aspire.Hosting/publishWithContainerFiles", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/publishWithContainerFilesFromResource", reqArgs) if err != nil { return nil, err } @@ -1026,7 +1026,7 @@ func (s *CSharpAppResource) WaitFor(dependency *IResource) (*IResourceWithWaitSu "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -1053,7 +1053,7 @@ func (s *CSharpAppResource) WaitForStart(dependency *IResource) (*IResourceWithW "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -1095,7 +1095,7 @@ func (s *CSharpAppResource) WaitForCompletion(dependency *IResource, exitCode *f if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -1190,7 +1190,7 @@ func (s *CSharpAppResource) WithHttpsDeveloperCertificate(password *ParameterRes if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -1215,7 +1215,7 @@ func (s *CSharpAppResource) WithParentRelationship(parent *IResource) (*IResourc "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -1228,7 +1228,7 @@ func (s *CSharpAppResource) WithChildRelationship(child *IResource) (*IResource, "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -1894,6 +1894,19 @@ func (s *ConnectionStringResource) WithConnectionPropertyValue(name string, valu return result.(*IResourceWithConnectionString), nil } +// GetConnectionProperty gets a connection property by key +func (s *ConnectionStringResource) GetConnectionProperty(key string) (*ReferenceExpression, error) { + reqArgs := map[string]any{ + "resource": SerializeValue(s.Handle()), + } + reqArgs["key"] = SerializeValue(key) + result, err := s.Client().InvokeCapability("Aspire.Hosting/getConnectionProperty", reqArgs) + if err != nil { + return nil, err + } + return result.(*ReferenceExpression), nil +} + // WithUrlsCallback customizes displayed URLs via callback func (s *ConnectionStringResource) WithUrlsCallback(callback func(...any) any) (*IResource, error) { reqArgs := map[string]any{ @@ -1990,7 +2003,7 @@ func (s *ConnectionStringResource) WaitFor(dependency *IResource) (*IResourceWit "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -2017,7 +2030,7 @@ func (s *ConnectionStringResource) WaitForStart(dependency *IResource) (*IResour "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -2059,7 +2072,7 @@ func (s *ConnectionStringResource) WaitForCompletion(dependency *IResource, exit if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -2105,7 +2118,7 @@ func (s *ConnectionStringResource) WithParentRelationship(parent *IResource) (*I "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -2118,7 +2131,7 @@ func (s *ConnectionStringResource) WithChildRelationship(child *IResource) (*IRe "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -2704,7 +2717,7 @@ func (s *ContainerRegistryResource) WithParentRelationship(parent *IResource) (* "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -2717,7 +2730,7 @@ func (s *ContainerRegistryResource) WithChildRelationship(child *IResource) (*IR "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -3262,7 +3275,7 @@ func (s *ContainerResource) WithBuildArg(name string, value *ParameterResource) } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) if err != nil { return nil, err } @@ -3276,7 +3289,7 @@ func (s *ContainerResource) WithBuildSecret(name string, value *ParameterResourc } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildSecret", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs) if err != nil { return nil, err } @@ -3842,7 +3855,7 @@ func (s *ContainerResource) WaitFor(dependency *IResource) (*IResourceWithWaitSu "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -3869,7 +3882,7 @@ func (s *ContainerResource) WaitForStart(dependency *IResource) (*IResourceWithW "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -3911,7 +3924,7 @@ func (s *ContainerResource) WaitForCompletion(dependency *IResource, exitCode *f if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -4006,7 +4019,7 @@ func (s *ContainerResource) WithHttpsDeveloperCertificate(password *ParameterRes if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -4031,7 +4044,7 @@ func (s *ContainerResource) WithParentRelationship(parent *IResource) (*IResourc "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -4044,7 +4057,7 @@ func (s *ContainerResource) WithChildRelationship(child *IResource) (*IResource, "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -5367,7 +5380,7 @@ func (s *DotnetToolResource) WaitFor(dependency *IResource) (*IResourceWithWaitS "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -5394,7 +5407,7 @@ func (s *DotnetToolResource) WaitForStart(dependency *IResource) (*IResourceWith "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -5436,7 +5449,7 @@ func (s *DotnetToolResource) WaitForCompletion(dependency *IResource, exitCode * if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -5531,7 +5544,7 @@ func (s *DotnetToolResource) WithHttpsDeveloperCertificate(password *ParameterRe if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -5556,7 +5569,7 @@ func (s *DotnetToolResource) WithParentRelationship(parent *IResource) (*IResour "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -5569,7 +5582,7 @@ func (s *DotnetToolResource) WithChildRelationship(child *IResource) (*IResource "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -6956,7 +6969,7 @@ func (s *ExecutableResource) WaitFor(dependency *IResource) (*IResourceWithWaitS "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -6983,7 +6996,7 @@ func (s *ExecutableResource) WaitForStart(dependency *IResource) (*IResourceWith "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -7025,7 +7038,7 @@ func (s *ExecutableResource) WaitForCompletion(dependency *IResource, exitCode * if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -7120,7 +7133,7 @@ func (s *ExecutableResource) WithHttpsDeveloperCertificate(password *ParameterRe if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -7145,7 +7158,7 @@ func (s *ExecutableResource) WithParentRelationship(parent *IResource) (*IResour "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -7158,7 +7171,7 @@ func (s *ExecutableResource) WithChildRelationship(child *IResource) (*IResource "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -7913,7 +7926,7 @@ func (s *ExternalServiceResource) WithParentRelationship(parent *IResource) (*IR "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -7926,7 +7939,7 @@ func (s *ExternalServiceResource) WithChildRelationship(child *IResource) (*IRes "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -9785,7 +9798,7 @@ func (s *ParameterResource) WithParentRelationship(parent *IResource) (*IResourc "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -9798,7 +9811,7 @@ func (s *ParameterResource) WithChildRelationship(child *IResource) (*IResource, "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -11320,7 +11333,7 @@ func (s *ProjectResource) PublishWithContainerFiles(source *IResourceWithContain } reqArgs["source"] = SerializeValue(source) reqArgs["destinationPath"] = SerializeValue(destinationPath) - result, err := s.Client().InvokeCapability("Aspire.Hosting/publishWithContainerFiles", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/publishWithContainerFilesFromResource", reqArgs) if err != nil { return nil, err } @@ -11345,7 +11358,7 @@ func (s *ProjectResource) WaitFor(dependency *IResource) (*IResourceWithWaitSupp "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -11372,7 +11385,7 @@ func (s *ProjectResource) WaitForStart(dependency *IResource) (*IResourceWithWai "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -11414,7 +11427,7 @@ func (s *ProjectResource) WaitForCompletion(dependency *IResource, exitCode *flo if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -11509,7 +11522,7 @@ func (s *ProjectResource) WithHttpsDeveloperCertificate(password *ParameterResou if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -11534,7 +11547,7 @@ func (s *ProjectResource) WithParentRelationship(parent *IResource) (*IResource, "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -11547,7 +11560,7 @@ func (s *ProjectResource) WithChildRelationship(child *IResource) (*IResource, e "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -12786,7 +12799,7 @@ func (s *TestDatabaseResource) WithBuildArg(name string, value *ParameterResourc } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) if err != nil { return nil, err } @@ -12800,7 +12813,7 @@ func (s *TestDatabaseResource) WithBuildSecret(name string, value *ParameterReso } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildSecret", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs) if err != nil { return nil, err } @@ -13366,7 +13379,7 @@ func (s *TestDatabaseResource) WaitFor(dependency *IResource) (*IResourceWithWai "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -13393,7 +13406,7 @@ func (s *TestDatabaseResource) WaitForStart(dependency *IResource) (*IResourceWi "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -13435,7 +13448,7 @@ func (s *TestDatabaseResource) WaitForCompletion(dependency *IResource, exitCode if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -13530,7 +13543,7 @@ func (s *TestDatabaseResource) WithHttpsDeveloperCertificate(password *Parameter if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -13555,7 +13568,7 @@ func (s *TestDatabaseResource) WithParentRelationship(parent *IResource) (*IReso "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -13568,7 +13581,7 @@ func (s *TestDatabaseResource) WithChildRelationship(child *IResource) (*IResour "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -14324,7 +14337,7 @@ func (s *TestRedisResource) WithBuildArg(name string, value *ParameterResource) } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) if err != nil { return nil, err } @@ -14338,7 +14351,7 @@ func (s *TestRedisResource) WithBuildSecret(name string, value *ParameterResourc } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildSecret", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs) if err != nil { return nil, err } @@ -14653,6 +14666,19 @@ func (s *TestRedisResource) WithReference(source *IResource, connectionName *str return result.(*IResourceWithEnvironment), nil } +// GetConnectionProperty gets a connection property by key +func (s *TestRedisResource) GetConnectionProperty(key string) (*ReferenceExpression, error) { + reqArgs := map[string]any{ + "resource": SerializeValue(s.Handle()), + } + reqArgs["key"] = SerializeValue(key) + result, err := s.Client().InvokeCapability("Aspire.Hosting/getConnectionProperty", reqArgs) + if err != nil { + return nil, err + } + return result.(*ReferenceExpression), nil +} + // WithReferenceUri adds a reference to a URI func (s *TestRedisResource) WithReferenceUri(name string, uri string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -14932,7 +14958,7 @@ func (s *TestRedisResource) WaitFor(dependency *IResource) (*IResourceWithWaitSu "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -14959,7 +14985,7 @@ func (s *TestRedisResource) WaitForStart(dependency *IResource) (*IResourceWithW "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -15001,7 +15027,7 @@ func (s *TestRedisResource) WaitForCompletion(dependency *IResource, exitCode *f if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -15096,7 +15122,7 @@ func (s *TestRedisResource) WithHttpsDeveloperCertificate(password *ParameterRes if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -15121,7 +15147,7 @@ func (s *TestRedisResource) WithParentRelationship(parent *IResource) (*IResourc "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -15134,7 +15160,7 @@ func (s *TestRedisResource) WithChildRelationship(child *IResource) (*IResource, "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } @@ -16074,7 +16100,7 @@ func (s *TestVaultResource) WithBuildArg(name string, value *ParameterResource) } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) if err != nil { return nil, err } @@ -16088,7 +16114,7 @@ func (s *TestVaultResource) WithBuildSecret(name string, value *ParameterResourc } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildSecret", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs) if err != nil { return nil, err } @@ -16654,7 +16680,7 @@ func (s *TestVaultResource) WaitFor(dependency *IResource) (*IResourceWithWaitSu "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitFor", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResource", reqArgs) if err != nil { return nil, err } @@ -16681,7 +16707,7 @@ func (s *TestVaultResource) WaitForStart(dependency *IResource) (*IResourceWithW "builder": SerializeValue(s.Handle()), } reqArgs["dependency"] = SerializeValue(dependency) - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForStart", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs) if err != nil { return nil, err } @@ -16723,7 +16749,7 @@ func (s *TestVaultResource) WaitForCompletion(dependency *IResource, exitCode *f if exitCode != nil { reqArgs["exitCode"] = SerializeValue(exitCode) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForCompletion", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs) if err != nil { return nil, err } @@ -16818,7 +16844,7 @@ func (s *TestVaultResource) WithHttpsDeveloperCertificate(password *ParameterRes if password != nil { reqArgs["password"] = SerializeValue(password) } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs) if err != nil { return nil, err } @@ -16843,7 +16869,7 @@ func (s *TestVaultResource) WithParentRelationship(parent *IResource) (*IResourc "builder": SerializeValue(s.Handle()), } reqArgs["parent"] = SerializeValue(parent) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParentRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs) if err != nil { return nil, err } @@ -16856,7 +16882,7 @@ func (s *TestVaultResource) WithChildRelationship(child *IResource) (*IResource, "builder": SerializeValue(s.Handle()), } reqArgs["child"] = SerializeValue(child) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withChildRelationship", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs) if err != nil { return nil, err } diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java index daa2e42b8d4..0cb7675f7e1 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java @@ -1020,7 +1020,7 @@ public IContainerFilesDestinationResource publishWithContainerFiles(IResourceWit reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("source", AspireClient.serializeValue(source)); reqArgs.put("destinationPath", AspireClient.serializeValue(destinationPath)); - return (IContainerFilesDestinationResource) getClient().invokeCapability("Aspire.Hosting/publishWithContainerFiles", reqArgs); + return (IContainerFilesDestinationResource) getClient().invokeCapability("Aspire.Hosting/publishWithContainerFilesFromResource", reqArgs); } /** Excludes the resource from the deployment manifest */ @@ -1035,7 +1035,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -1052,7 +1052,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -1079,7 +1079,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -1144,7 +1144,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -1159,7 +1159,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -1167,7 +1167,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -1607,6 +1607,14 @@ public IResourceWithConnectionString withConnectionPropertyValue(String name, St return (IResourceWithConnectionString) getClient().invokeCapability("Aspire.Hosting/withConnectionPropertyValue", reqArgs); } + /** Gets a connection property by key */ + public ReferenceExpression getConnectionProperty(String key) { + Map reqArgs = new HashMap<>(); + reqArgs.put("resource", AspireClient.serializeValue(getHandle())); + reqArgs.put("key", AspireClient.serializeValue(key)); + return (ReferenceExpression) getClient().invokeCapability("Aspire.Hosting/getConnectionProperty", reqArgs); + } + /** Customizes displayed URLs via callback */ public IResource withUrlsCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -1672,7 +1680,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -1689,7 +1697,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -1716,7 +1724,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -1747,7 +1755,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -1755,7 +1763,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -2142,7 +2150,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -2150,7 +2158,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -2506,7 +2514,7 @@ public ContainerResource withBuildArg(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -2515,7 +2523,7 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildSecret", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } /** Configures endpoint proxy support */ @@ -2901,7 +2909,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -2918,7 +2926,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -2945,7 +2953,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -3010,7 +3018,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -3025,7 +3033,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -3033,7 +3041,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -3916,7 +3924,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -3933,7 +3941,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -3960,7 +3968,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -4025,7 +4033,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -4040,7 +4048,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -4048,7 +4056,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -4964,7 +4972,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -4981,7 +4989,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -5008,7 +5016,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -5073,7 +5081,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -5088,7 +5096,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -5096,7 +5104,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -5598,7 +5606,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -5606,7 +5614,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -6854,7 +6862,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -6862,7 +6870,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -7868,7 +7876,7 @@ public IContainerFilesDestinationResource publishWithContainerFiles(IResourceWit reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("source", AspireClient.serializeValue(source)); reqArgs.put("destinationPath", AspireClient.serializeValue(destinationPath)); - return (IContainerFilesDestinationResource) getClient().invokeCapability("Aspire.Hosting/publishWithContainerFiles", reqArgs); + return (IContainerFilesDestinationResource) getClient().invokeCapability("Aspire.Hosting/publishWithContainerFilesFromResource", reqArgs); } /** Excludes the resource from the deployment manifest */ @@ -7883,7 +7891,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -7900,7 +7908,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -7927,7 +7935,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -7992,7 +8000,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -8007,7 +8015,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -8015,7 +8023,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -8839,7 +8847,7 @@ public ContainerResource withBuildArg(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -8848,7 +8856,7 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildSecret", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } /** Configures endpoint proxy support */ @@ -9234,7 +9242,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -9251,7 +9259,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -9278,7 +9286,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -9343,7 +9351,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -9358,7 +9366,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -9366,7 +9374,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -9862,7 +9870,7 @@ public ContainerResource withBuildArg(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -9871,7 +9879,7 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildSecret", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } /** Configures endpoint proxy support */ @@ -10077,6 +10085,14 @@ public IResourceWithEnvironment withReference(IResource source, String connectio return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReference", reqArgs); } + /** Gets a connection property by key */ + public ReferenceExpression getConnectionProperty(String key) { + Map reqArgs = new HashMap<>(); + reqArgs.put("resource", AspireClient.serializeValue(getHandle())); + reqArgs.put("key", AspireClient.serializeValue(key)); + return (ReferenceExpression) getClient().invokeCapability("Aspire.Hosting/getConnectionProperty", reqArgs); + } + /** Adds a reference to a URI */ public IResourceWithEnvironment withReferenceUri(String name, String uri) { Map reqArgs = new HashMap<>(); @@ -10275,7 +10291,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -10292,7 +10308,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -10319,7 +10335,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -10384,7 +10400,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -10399,7 +10415,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -10407,7 +10423,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ @@ -11034,7 +11050,7 @@ public ContainerResource withBuildArg(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -11043,7 +11059,7 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildSecret", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } /** Configures endpoint proxy support */ @@ -11429,7 +11445,7 @@ public IResourceWithWaitSupport waitFor(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitFor", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResource", reqArgs); } /** Waits for another resource with specific behavior */ @@ -11446,7 +11462,7 @@ public IResourceWithWaitSupport waitForStart(IResource dependency) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("dependency", AspireClient.serializeValue(dependency)); - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForStart", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceStart", reqArgs); } /** Waits for another resource to start with specific behavior */ @@ -11473,7 +11489,7 @@ public IResourceWithWaitSupport waitForCompletion(IResource dependency, Double e if (exitCode != null) { reqArgs.put("exitCode", AspireClient.serializeValue(exitCode)); } - return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForCompletion", reqArgs); + return (IResourceWithWaitSupport) getClient().invokeCapability("Aspire.Hosting/waitForResourceCompletion", reqArgs); } /** Adds a health check by key */ @@ -11538,7 +11554,7 @@ public IResourceWithEnvironment withHttpsDeveloperCertificate(ParameterResource if (password != null) { reqArgs.put("password", AspireClient.serializeValue(password)); } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withHttpsDeveloperCertificate", reqArgs); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", reqArgs); } /** Removes HTTPS certificate configuration */ @@ -11553,7 +11569,7 @@ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("parent", AspireClient.serializeValue(parent)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withParentRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderParentRelationship", reqArgs); } /** Sets a child relationship */ @@ -11561,7 +11577,7 @@ public IResource withChildRelationship(IResource child) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("child", AspireClient.serializeValue(child)); - return (IResource) getClient().invokeCapability("Aspire.Hosting/withChildRelationship", reqArgs); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderChildRelationship", reqArgs); } /** Sets the icon for the resource */ diff --git a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py index 050a517d447..e61b6a135c6 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py +++ b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py @@ -578,7 +578,7 @@ def publish_with_container_files(self, source: IResourceWithContainerFiles, dest args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["source"] = serialize_value(source) args["destinationPath"] = serialize_value(destination_path) - return self._client.invoke_capability("Aspire.Hosting/publishWithContainerFiles", args) + return self._client.invoke_capability("Aspire.Hosting/publishWithContainerFilesFromResource", args) def exclude_from_manifest(self) -> IResource: """Excludes the resource from the deployment manifest""" @@ -589,7 +589,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -602,7 +602,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -621,7 +621,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -669,7 +669,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -680,13 +680,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -1021,6 +1021,12 @@ def with_connection_property_value(self, name: str, value: str) -> IResourceWith args["value"] = serialize_value(value) return self._client.invoke_capability("Aspire.Hosting/withConnectionPropertyValue", args) + def get_connection_property(self, key: str) -> ReferenceExpression: + """Gets a connection property by key""" + args: Dict[str, Any] = { "resource": serialize_value(self._handle) } + args["key"] = serialize_value(key) + return self._client.invoke_capability("Aspire.Hosting/getConnectionProperty", args) + def with_urls_callback(self, callback: Callable[[ResourceUrlsCallbackContext], None]) -> IResource: """Customizes displayed URLs via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -1071,7 +1077,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -1084,7 +1090,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -1103,7 +1109,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -1127,13 +1133,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -1424,13 +1430,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -1695,14 +1701,14 @@ def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResour args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildSecret", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" @@ -1983,7 +1989,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -1996,7 +2002,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -2015,7 +2021,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -2063,7 +2069,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -2074,13 +2080,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -2728,7 +2734,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -2741,7 +2747,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -2760,7 +2766,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -2808,7 +2814,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -2819,13 +2825,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -3500,7 +3506,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -3513,7 +3519,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -3532,7 +3538,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -3580,7 +3586,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -3591,13 +3597,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -3971,13 +3977,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -4914,13 +4920,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -5673,7 +5679,7 @@ def publish_with_container_files(self, source: IResourceWithContainerFiles, dest args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["source"] = serialize_value(source) args["destinationPath"] = serialize_value(destination_path) - return self._client.invoke_capability("Aspire.Hosting/publishWithContainerFiles", args) + return self._client.invoke_capability("Aspire.Hosting/publishWithContainerFilesFromResource", args) def exclude_from_manifest(self) -> IResource: """Excludes the resource from the deployment manifest""" @@ -5684,7 +5690,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -5697,7 +5703,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -5716,7 +5722,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -5764,7 +5770,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -5775,13 +5781,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -6415,14 +6421,14 @@ def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResour args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildSecret", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" @@ -6703,7 +6709,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -6716,7 +6722,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -6735,7 +6741,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -6783,7 +6789,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -6794,13 +6800,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -7166,14 +7172,14 @@ def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResour args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildSecret", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" @@ -7326,6 +7332,12 @@ def with_reference(self, source: IResource, connection_name: str | None = None, args["name"] = serialize_value(name) return self._client.invoke_capability("Aspire.Hosting/withReference", args) + def get_connection_property(self, key: str) -> ReferenceExpression: + """Gets a connection property by key""" + args: Dict[str, Any] = { "resource": serialize_value(self._handle) } + args["key"] = serialize_value(key) + return self._client.invoke_capability("Aspire.Hosting/getConnectionProperty", args) + def with_reference_uri(self, name: str, uri: str) -> IResourceWithEnvironment: """Adds a reference to a URI""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7468,7 +7480,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -7481,7 +7493,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -7500,7 +7512,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -7548,7 +7560,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -7559,13 +7571,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" @@ -8037,14 +8049,14 @@ def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResour args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withBuildSecret", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" @@ -8325,7 +8337,7 @@ def wait_for(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to be ready""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitFor", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResource", args) def wait_for_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource with specific behavior""" @@ -8338,7 +8350,7 @@ def wait_for_start(self, dependency: IResource) -> IResourceWithWaitSupport: """Waits for another resource to start""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) - return self._client.invoke_capability("Aspire.Hosting/waitForStart", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceStart", args) def wait_for_start_with_behavior(self, dependency: IResource, wait_behavior: WaitBehavior) -> IResourceWithWaitSupport: """Waits for another resource to start with specific behavior""" @@ -8357,7 +8369,7 @@ def wait_for_completion(self, dependency: IResource, exit_code: float = 0) -> IR args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["dependency"] = serialize_value(dependency) args["exitCode"] = serialize_value(exit_code) - return self._client.invoke_capability("Aspire.Hosting/waitForCompletion", args) + return self._client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args) def with_health_check(self, key: str) -> IResource: """Adds a health check by key""" @@ -8405,7 +8417,7 @@ def with_https_developer_certificate(self, password: ParameterResource | None = args: Dict[str, Any] = { "builder": serialize_value(self._handle) } if password is not None: args["password"] = serialize_value(password) - return self._client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args) + return self._client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args) def without_https_certificate(self) -> IResourceWithEnvironment: """Removes HTTPS certificate configuration""" @@ -8416,13 +8428,13 @@ def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["parent"] = serialize_value(parent) - return self._client.invoke_capability("Aspire.Hosting/withParentRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args) def with_child_relationship(self, child: IResource) -> IResource: """Sets a child relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["child"] = serialize_value(child) - return self._client.invoke_capability("Aspire.Hosting/withChildRelationship", args) + return self._client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args) def with_icon_name(self, icon_name: str, icon_variant: IconVariant = None) -> IResource: """Sets the icon for the resource""" diff --git a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs index 8002661db95..8cf8e43dc67 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs +++ b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs @@ -1204,7 +1204,7 @@ impl CSharpAppResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("source".to_string(), source.handle().to_json()); args.insert("destinationPath".to_string(), serde_json::to_value(&destination_path).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/publishWithContainerFiles", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/publishWithContainerFilesFromResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IContainerFilesDestinationResource::new(handle, self.client.clone())) } @@ -1223,7 +1223,7 @@ impl CSharpAppResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -1244,7 +1244,7 @@ impl CSharpAppResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -1277,7 +1277,7 @@ impl CSharpAppResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -1353,7 +1353,7 @@ impl CSharpAppResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -1372,7 +1372,7 @@ impl CSharpAppResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -1382,7 +1382,7 @@ impl CSharpAppResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -1945,6 +1945,15 @@ impl ConnectionStringResource { Ok(IResourceWithConnectionString::new(handle, self.client.clone())) } + /// Gets a connection property by key + pub fn get_connection_property(&self, key: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("resource".to_string(), self.handle.to_json()); + args.insert("key".to_string(), serde_json::to_value(&key).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/getConnectionProperty", args)?; + Ok(serde_json::from_value(result)?) + } + /// Customizes displayed URLs via callback pub fn with_urls_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -2019,7 +2028,7 @@ impl ConnectionStringResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -2040,7 +2049,7 @@ impl ConnectionStringResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -2073,7 +2082,7 @@ impl ConnectionStringResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -2109,7 +2118,7 @@ impl ConnectionStringResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -2119,7 +2128,7 @@ impl ConnectionStringResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -2586,7 +2595,7 @@ impl ContainerRegistryResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -2596,7 +2605,7 @@ impl ContainerRegistryResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -3033,7 +3042,7 @@ impl ContainerResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -3044,7 +3053,7 @@ impl ContainerResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildSecret", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -3494,7 +3503,7 @@ impl ContainerResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -3515,7 +3524,7 @@ impl ContainerResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -3548,7 +3557,7 @@ impl ContainerResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -3624,7 +3633,7 @@ impl ContainerResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -3643,7 +3652,7 @@ impl ContainerResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -3653,7 +3662,7 @@ impl ContainerResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -4802,7 +4811,7 @@ impl DotnetToolResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -4823,7 +4832,7 @@ impl DotnetToolResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -4856,7 +4865,7 @@ impl DotnetToolResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -4932,7 +4941,7 @@ impl DotnetToolResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -4951,7 +4960,7 @@ impl DotnetToolResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -4961,7 +4970,7 @@ impl DotnetToolResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -6090,7 +6099,7 @@ impl ExecutableResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -6111,7 +6120,7 @@ impl ExecutableResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -6144,7 +6153,7 @@ impl ExecutableResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -6220,7 +6229,7 @@ impl ExecutableResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -6239,7 +6248,7 @@ impl ExecutableResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -6249,7 +6258,7 @@ impl ExecutableResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -6868,7 +6877,7 @@ impl ExternalServiceResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -6878,7 +6887,7 @@ impl ExternalServiceResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -8778,7 +8787,7 @@ impl ParameterResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -8788,7 +8797,7 @@ impl ParameterResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -10084,7 +10093,7 @@ impl ProjectResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("source".to_string(), source.handle().to_json()); args.insert("destinationPath".to_string(), serde_json::to_value(&destination_path).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/publishWithContainerFiles", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/publishWithContainerFilesFromResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IContainerFilesDestinationResource::new(handle, self.client.clone())) } @@ -10103,7 +10112,7 @@ impl ProjectResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -10124,7 +10133,7 @@ impl ProjectResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -10157,7 +10166,7 @@ impl ProjectResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -10233,7 +10242,7 @@ impl ProjectResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -10252,7 +10261,7 @@ impl ProjectResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -10262,7 +10271,7 @@ impl ProjectResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -11400,7 +11409,7 @@ impl TestDatabaseResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -11411,7 +11420,7 @@ impl TestDatabaseResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildSecret", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -11861,7 +11870,7 @@ impl TestDatabaseResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -11882,7 +11891,7 @@ impl TestDatabaseResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -11915,7 +11924,7 @@ impl TestDatabaseResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -11991,7 +12000,7 @@ impl TestDatabaseResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -12010,7 +12019,7 @@ impl TestDatabaseResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -12020,7 +12029,7 @@ impl TestDatabaseResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -12636,7 +12645,7 @@ impl TestRedisResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -12647,7 +12656,7 @@ impl TestRedisResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildSecret", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -12893,6 +12902,15 @@ impl TestRedisResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Gets a connection property by key + pub fn get_connection_property(&self, key: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("resource".to_string(), self.handle.to_json()); + args.insert("key".to_string(), serde_json::to_value(&key).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/getConnectionProperty", args)?; + Ok(serde_json::from_value(result)?) + } + /// Adds a reference to a URI pub fn with_reference_uri(&self, name: &str, uri: &str) -> Result> { let mut args: HashMap = HashMap::new(); @@ -13119,7 +13137,7 @@ impl TestRedisResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -13140,7 +13158,7 @@ impl TestRedisResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -13173,7 +13191,7 @@ impl TestRedisResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -13249,7 +13267,7 @@ impl TestRedisResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -13268,7 +13286,7 @@ impl TestRedisResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -13278,7 +13296,7 @@ impl TestRedisResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -14036,7 +14054,7 @@ impl TestVaultResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -14047,7 +14065,7 @@ impl TestVaultResource { args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withBuildSecret", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -14497,7 +14515,7 @@ impl TestVaultResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitFor", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResource", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -14518,7 +14536,7 @@ impl TestVaultResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("dependency".to_string(), dependency.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/waitForStart", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceStart", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -14551,7 +14569,7 @@ impl TestVaultResource { if let Some(ref v) = exit_code { args.insert("exitCode".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); } - let result = self.client.invoke_capability("Aspire.Hosting/waitForCompletion", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/waitForResourceCompletion", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithWaitSupport::new(handle, self.client.clone())) } @@ -14627,7 +14645,7 @@ impl TestVaultResource { if let Some(ref v) = password { args.insert("password".to_string(), v.handle().to_json()); } - let result = self.client.invoke_capability("Aspire.Hosting/withHttpsDeveloperCertificate", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withParameterHttpsDeveloperCertificate", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -14646,7 +14664,7 @@ impl TestVaultResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("parent".to_string(), parent.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParentRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderParentRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } @@ -14656,7 +14674,7 @@ impl TestVaultResource { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("child".to_string(), child.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withChildRelationship", args)?; + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderChildRelationship", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResource::new(handle, self.client.clone())) } diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt index 367388398f6..0682a945fa3 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt @@ -168,7 +168,7 @@ ] }, { - CapabilityId: Aspire.Hosting/waitFor, + CapabilityId: Aspire.Hosting/waitForResource, MethodName: waitFor, TargetType: { TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport, @@ -182,7 +182,7 @@ ] }, { - CapabilityId: Aspire.Hosting/waitForCompletion, + CapabilityId: Aspire.Hosting/waitForResourceCompletion, MethodName: waitForCompletion, TargetType: { TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport, @@ -196,7 +196,7 @@ ] }, { - CapabilityId: Aspire.Hosting/waitForStart, + CapabilityId: Aspire.Hosting/waitForResourceStart, MethodName: waitForStart, TargetType: { TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport, @@ -294,11 +294,11 @@ ] }, { - CapabilityId: Aspire.Hosting/withBuildArg, - MethodName: withBuildArg, + CapabilityId: Aspire.Hosting/withBuilderChildRelationship, + MethodName: withChildRelationship, TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource, + IsInterface: true }, ExpandedTargetTypes: [ { @@ -308,11 +308,11 @@ ] }, { - CapabilityId: Aspire.Hosting/withBuildSecret, - MethodName: withBuildSecret, + CapabilityId: Aspire.Hosting/withBuilderParentRelationship, + MethodName: withParentRelationship, TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource, + IsInterface: true }, ExpandedTargetTypes: [ { @@ -335,20 +335,6 @@ } ] }, - { - CapabilityId: Aspire.Hosting/withChildRelationship, - MethodName: withChildRelationship, - TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource, - IsInterface: true - }, - ExpandedTargetTypes: [ - { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false - } - ] - }, { CapabilityId: Aspire.Hosting/withCommand, MethodName: withCommand, @@ -685,20 +671,6 @@ } ] }, - { - CapabilityId: Aspire.Hosting/withHttpsDeveloperCertificate, - MethodName: withHttpsDeveloperCertificate, - TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment, - IsInterface: true - }, - ExpandedTargetTypes: [ - { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false - } - ] - }, { CapabilityId: Aspire.Hosting/withHttpsEndpoint, MethodName: withHttpsEndpoint, @@ -868,10 +840,38 @@ ] }, { - CapabilityId: Aspire.Hosting/withParentRelationship, - MethodName: withParentRelationship, + CapabilityId: Aspire.Hosting/withParameterBuildArg, + MethodName: withBuildArg, TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource, + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + }, + ExpandedTargetTypes: [ + { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + } + ] + }, + { + CapabilityId: Aspire.Hosting/withParameterBuildSecret, + MethodName: withBuildSecret, + TargetType: { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + }, + ExpandedTargetTypes: [ + { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + } + ] + }, + { + CapabilityId: Aspire.Hosting/withParameterHttpsDeveloperCertificate, + MethodName: withHttpsDeveloperCertificate, + TargetType: { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment, IsInterface: true }, ExpandedTargetTypes: [ diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts index e96893861b9..7062cbbf735 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts @@ -4623,6 +4623,15 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -4735,7 +4744,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4765,7 +4774,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4811,7 +4820,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4864,7 +4873,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4879,7 +4888,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5386,6 +5395,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -5822,7 +5836,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -5837,7 +5851,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -6672,7 +6686,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new ContainerResource(result, this._client); @@ -6687,7 +6701,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new ContainerResource(result, this._client); @@ -7316,7 +7330,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -7346,7 +7360,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -7392,7 +7406,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -7497,7 +7511,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -7528,7 +7542,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -7543,7 +7557,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -9219,7 +9233,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9249,7 +9263,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9279,7 +9293,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9325,7 +9339,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9430,7 +9444,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9461,7 +9475,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9476,7 +9490,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11181,7 +11195,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11211,7 +11225,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11257,7 +11271,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11362,7 +11376,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11393,7 +11407,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11408,7 +11422,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13053,7 +13067,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13083,7 +13097,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13129,7 +13143,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13234,7 +13248,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13265,7 +13279,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13280,7 +13294,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14476,7 +14490,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -14491,7 +14505,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -15356,7 +15370,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -15371,7 +15385,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -16629,7 +16643,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -16659,7 +16673,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -16689,7 +16703,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -16735,7 +16749,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -16840,7 +16854,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -16871,7 +16885,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -16886,7 +16900,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -18055,7 +18069,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -18070,7 +18084,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -18699,7 +18713,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -18729,7 +18743,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -18775,7 +18789,7 @@ export class TestDatabaseResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -18880,7 +18894,7 @@ export class TestDatabaseResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -18911,7 +18925,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -18926,7 +18940,7 @@ export class TestDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new TestDatabaseResource(result, this._client); @@ -20184,7 +20198,7 @@ export class TestRedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new TestRedisResource(result, this._client); @@ -20199,7 +20213,7 @@ export class TestRedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new TestRedisResource(result, this._client); @@ -20561,6 +20575,15 @@ export class TestRedisResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withReferenceUriInternal(name: string, uri: string): Promise { const rpcArgs: Record = { builder: this._handle, name, uri }; @@ -20858,7 +20881,7 @@ export class TestRedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new TestRedisResource(result, this._client); @@ -20888,7 +20911,7 @@ export class TestRedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new TestRedisResource(result, this._client); @@ -20934,7 +20957,7 @@ export class TestRedisResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new TestRedisResource(result, this._client); @@ -21039,7 +21062,7 @@ export class TestRedisResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new TestRedisResource(result, this._client); @@ -21070,7 +21093,7 @@ export class TestRedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new TestRedisResource(result, this._client); @@ -21085,7 +21108,7 @@ export class TestRedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new TestRedisResource(result, this._client); @@ -22019,6 +22042,11 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -22607,7 +22635,7 @@ export class TestVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new TestVaultResource(result, this._client); @@ -22622,7 +22650,7 @@ export class TestVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new TestVaultResource(result, this._client); @@ -23251,7 +23279,7 @@ export class TestVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new TestVaultResource(result, this._client); @@ -23281,7 +23309,7 @@ export class TestVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new TestVaultResource(result, this._client); @@ -23327,7 +23355,7 @@ export class TestVaultResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new TestVaultResource(result, this._client); @@ -23432,7 +23460,7 @@ export class TestVaultResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new TestVaultResource(result, this._client); @@ -23463,7 +23491,7 @@ export class TestVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new TestVaultResource(result, this._client); @@ -23478,7 +23506,7 @@ export class TestVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new TestVaultResource(result, this._client); @@ -24621,7 +24649,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -24880,7 +24908,7 @@ export class Resource extends ResourceBuilderBase { private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -24895,7 +24923,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -25651,6 +25679,15 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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) => { @@ -25728,6 +25765,11 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Subscribes to the ConnectionStringAvailable event */ onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); @@ -26380,7 +26422,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -26569,7 +26611,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -26599,7 +26641,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -26630,7 +26672,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); diff --git a/tests/Aspire.Hosting.RemoteHost.Tests/AttributeDataReaderTests.cs b/tests/Aspire.Hosting.RemoteHost.Tests/AttributeDataReaderTests.cs index faf7a0bd9e8..b7565415944 100644 --- a/tests/Aspire.Hosting.RemoteHost.Tests/AttributeDataReaderTests.cs +++ b/tests/Aspire.Hosting.RemoteHost.Tests/AttributeDataReaderTests.cs @@ -69,6 +69,14 @@ public void HasAspireExportIgnoreData_IgnoresAttribute_WithDifferentNamespace() Assert.False(result); } + [Fact] + public void HasAspireExportIgnoreData_FindsOfficialAttribute_OnType() + { + var result = AttributeDataReader.HasAspireExportIgnoreData(typeof(OfficialIgnoredType)); + + Assert.True(result); + } + [Fact] public void HasAspireDtoData_FindsOfficialAttribute() { @@ -216,6 +224,11 @@ public OfficialMethodsResource(string name) : base(name) { } public void DoSomething() { } } + [AspireExportIgnore] + public class OfficialIgnoredType + { + } + [AspireDto] public class OfficialDtoType { From c25c645854a18639fe5852c1768459854ece20ab Mon Sep 17 00:00:00 2001 From: "Maddy Montaquila (Leger)" Date: Wed, 18 Mar 2026 15:59:24 -0400 Subject: [PATCH 05/49] Consolidate WithEnvironment polyglot exports using AspireUnionAttribute (#15333) * Consolidate WithEnvironment exports using AspireUnionAttribute Merge the separate withEnvironment (string) and withEnvironmentExpression (ReferenceExpression) polyglot exports into a single withEnvironment export using [AspireUnion] to accept string | ReferenceExpression | EndpointReference. This gives TypeScript AppHost users a single, clean API: await api.withEnvironment('KEY', 'value'); await api.withEnvironment('KEY', refExpr`redis://${endpoint}`); await api.withEnvironment('KEY', endpoint); Instead of requiring separate method names for each value type. Also adds EndpointReference support which was previously unexported, and handles object target type in AtsMarshaller.ConvertPrimitive for correct union parameter deserialization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Expand WithEnvironment union with ParameterResource, ConnectionString, and IValueProvider fallback - Add IResourceBuilder and IResourceBuilder to the AspireUnion - Add IValueProvider+IManifestExpressionProvider runtime fallback for extensibility (e.g. BicepOutputReference) - Remove withEnvironmentEndpoint separate export (covered by union) - Remove sync withEnvironmentCallback export, rename async to withEnvironmentCallback - Update codegen snapshots Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update TypeScript apphost environment usage Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refresh polyglot codegen snapshots Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add ReferenceExpression apphost coverage Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix TypeScript polyglot validation apphost Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Make WithEnvironment union overload internal Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address WithEnvironment review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: David Fowler Co-authored-by: Sebastien Ros Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../aspire.config.json | 20 + .../ValidationAppHost/apphost.ts | 17 +- .../Ats/AtsMarshaller.cs | 22 + .../ResourceBuilderExtensions.cs | 72 +- ...TwoPassScanningGeneratedAspire.verified.go | 376 ++------ ...oPassScanningGeneratedAspire.verified.java | 296 ++----- ...TwoPassScanningGeneratedAspire.verified.py | 232 ++--- ...TwoPassScanningGeneratedAspire.verified.rs | 320 ++----- ...ContainerResourceCapabilities.verified.txt | 28 - ...TwoPassScanningGeneratedAspire.verified.ts | 837 +++++------------- 10 files changed, 594 insertions(+), 1626 deletions(-) create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/aspire.config.json diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/aspire.config.json new file mode 100644 index 00000000000..53a14823130 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.SqlServer/aspire.config.json @@ -0,0 +1,20 @@ +{ + "appHost": { + "path": "../apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:55686;http://localhost:57768", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:51980", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:28684" + } + } + }, + "packages": { + "Aspire.Hosting.SqlServer": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts index 3f2cd131d3b..fabecdca04a 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts @@ -69,18 +69,23 @@ const builtConnectionString = await builder.addConnectionStringBuilder("customcs await builtConnectionString.withConnectionProperty("Host", expr); await builtConnectionString.withConnectionPropertyValue("Mode", "Development"); +const envConnectionString = await builder.addConnectionString("envcs"); + // =================================================================== // ResourceBuilderExtensions.cs — NEW exports on ContainerResource // =================================================================== -// withEnvironmentEndpoint -await container.withEnvironmentEndpoint("MY_ENDPOINT", endpoint); +// withEnvironment — with EndpointReference +await container.withEnvironment("MY_ENDPOINT", endpoint); + +// withEnvironment — with ReferenceExpression +await container.withEnvironment("MY_EXPR", expr); -// withEnvironmentParameter -await container.withEnvironmentParameter("MY_PARAM", configParam); +// withEnvironment — with ParameterResource +await container.withEnvironment("MY_PARAM", configParam); -// withEnvironmentConnectionString -await container.withEnvironmentConnectionString("MY_CONN", builtConnectionString); +// withEnvironment — with connection string resource +await container.withEnvironment("MY_CONN", envConnectionString); // withConnectionProperty — with ReferenceExpression await builtConnectionString.withConnectionProperty("Endpoint", expr); diff --git a/src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs b/src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs index 2b0f2e8bd2e..9433614a013 100644 --- a/src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs +++ b/src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs @@ -480,6 +480,28 @@ public static bool IsSimpleType(Type type) { var underlyingType = Nullable.GetUnderlyingType(targetType) ?? targetType; + // When target type is object (union parameter), infer from JSON value + if (underlyingType == typeof(object)) + { + if (value.TryGetValue(out var s)) + { + return s; + } + if (value.TryGetValue(out var b)) + { + return b; + } + if (value.TryGetValue(out var l)) + { + return l; + } + if (value.TryGetValue(out var d)) + { + return d; + } + return value.ToJsonString(); + } + // Handle enums - they come as string names if (underlyingType.IsEnum) { diff --git a/src/Aspire.Hosting/ResourceBuilderExtensions.cs b/src/Aspire.Hosting/ResourceBuilderExtensions.cs index 3ddd0825dd4..d0568f41e28 100644 --- a/src/Aspire.Hosting/ResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ResourceBuilderExtensions.cs @@ -32,7 +32,7 @@ public static class ResourceBuilderExtensions /// The name of the environment variable. /// The value of the environment variable. /// The . - [AspireExport("withEnvironment", Description = "Sets an environment variable")] + [AspireExportIgnore(Reason = "Polyglot app hosts use the internal withEnvironment dispatcher export.")] public static IResourceBuilder WithEnvironment(this IResourceBuilder builder, string name, string? value) where T : IResourceWithEnvironment { ArgumentNullException.ThrowIfNull(builder); @@ -70,27 +70,12 @@ public static IResourceBuilder WithEnvironment(this IResourceBuilder bu /// /// Adds an environment variable to the resource with a reference expression value. /// - /// - /// - /// This overload enables polyglot hosts to set environment variables using dynamic - /// expressions that reference endpoints, parameters, and other value providers. - /// - /// - /// Usage from TypeScript: - /// - /// const redis = await builder.addRedis("cache"); - /// const endpoint = await redis.getEndpoint("tcp"); - /// const expr = refExpr`redis://${endpoint}:6379`; - /// await api.withEnvironmentExpression("REDIS_URL", expr); - /// - /// - /// /// The resource type. /// The resource builder. /// The name of the environment variable. /// A ReferenceExpression that will be evaluated at runtime. /// The . - [AspireExport("withEnvironmentExpression", Description = "Adds an environment variable with a reference expression")] + [AspireExportIgnore(Reason = "Polyglot app hosts use the internal withEnvironment dispatcher export.")] public static IResourceBuilder WithEnvironment(this IResourceBuilder builder, string name, ReferenceExpression value) where T : IResourceWithEnvironment { @@ -132,7 +117,7 @@ public static IResourceBuilder WithEnvironment(this IResourceBuilder bu /// The resource builder. /// A callback that allows for deferred execution for computing many environment variables. This runs after resources have been allocated by the orchestrator and allows access to other resources to resolve computed data, e.g. connection strings, ports. /// The . - [AspireExport("withEnvironmentCallback", Description = "Sets environment variables via callback")] + [AspireExportIgnore(Reason = "Polyglot app hosts use the async callback overload.")] public static IResourceBuilder WithEnvironment(this IResourceBuilder builder, Action callback) where T : IResourceWithEnvironment { ArgumentNullException.ThrowIfNull(builder); @@ -148,7 +133,7 @@ public static IResourceBuilder WithEnvironment(this IResourceBuilder bu /// The resource builder. /// A callback that allows for deferred execution for computing many environment variables. This runs after resources have been allocated by the orchestrator and allows access to other resources to resolve computed data, e.g. connection strings, ports. /// The . - [AspireExport("withEnvironmentCallbackAsync", Description = "Sets environment variables via async callback")] + [AspireExport("withEnvironmentCallback", Description = "Sets environment variables via callback")] public static IResourceBuilder WithEnvironment(this IResourceBuilder builder, Func callback) where T : IResourceWithEnvironment { ArgumentNullException.ThrowIfNull(builder); @@ -181,6 +166,55 @@ public static IResourceBuilder WithEnvironment(this IResourceBuilder bu }); } + /// + /// Adds an environment variable to the resource. + /// + /// The resource type. + /// The resource builder. + /// The name of the environment variable. + /// The value of the environment variable. + /// The . + /// Thrown when , , or is null. + /// Thrown when is not a supported type. + [AspireExport("withEnvironment", Description = "Sets an environment variable on the resource")] + internal static IResourceBuilder WithEnvironment( + this IResourceBuilder builder, + string name, + [AspireUnion(typeof(string), typeof(ReferenceExpression), typeof(EndpointReference), typeof(IResourceBuilder), typeof(IResourceBuilder))] object value) + where T : IResourceWithEnvironment + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(name); + ArgumentNullException.ThrowIfNull(value); + + return value switch + { + string s => builder.WithEnvironment(name, s), + ReferenceExpression expr => builder.WithEnvironment(name, expr), + EndpointReference endpoint => builder.WithEnvironment(name, endpoint), + IResourceBuilder param => builder.WithEnvironment(name, param), + IResourceBuilder connStr => builder.WithEnvironment(name, connStr), + IValueProvider and IManifestExpressionProvider => WithEnvironmentValueProvider(builder, name, value), + _ => throw new ArgumentException( + $"Unsupported value type '{value.GetType().Name}'. Expected string, ReferenceExpression, EndpointReference, ParameterResource, connection string resource, or an IValueProvider.", + nameof(value)) + }; + } + + private static IResourceBuilder WithEnvironmentValueProvider(IResourceBuilder builder, string name, object value) + where T : IResourceWithEnvironment + { + if (value is IValueWithReferences valueWithReferences) + { + WalkAndLinkResourceReferences(builder, valueWithReferences.References); + } + + return builder.WithEnvironment(context => + { + context.EnvironmentVariables[name] = value; + }); + } + /// /// Adds an environment variable to the resource with the URL from the . /// diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go index 9c1b48f5d90..f98e4db0566 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go @@ -568,34 +568,6 @@ func (s *CSharpAppResource) WithRequiredCommand(command string, helpLink *string return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *CSharpAppResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *CSharpAppResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *CSharpAppResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -611,29 +583,28 @@ func (s *CSharpAppResource) WithEnvironmentCallback(callback func(...any) any) ( return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *CSharpAppResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *CSharpAppResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *CSharpAppResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *CSharpAppResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } @@ -3411,34 +3382,6 @@ func (s *ContainerResource) WithRequiredCommand(command string, helpLink *string return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *ContainerResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *ContainerResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *ContainerResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -3454,29 +3397,28 @@ func (s *ContainerResource) WithEnvironmentCallback(callback func(...any) any) ( return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *ContainerResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *ContainerResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *ContainerResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *ContainerResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } @@ -4936,34 +4878,6 @@ func (s *DotnetToolResource) WithRequiredCommand(command string, helpLink *strin return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *DotnetToolResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *DotnetToolResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *DotnetToolResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -4979,29 +4893,28 @@ func (s *DotnetToolResource) WithEnvironmentCallback(callback func(...any) any) return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *DotnetToolResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *DotnetToolResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *DotnetToolResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *DotnetToolResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } @@ -6525,34 +6438,6 @@ func (s *ExecutableResource) WithRequiredCommand(command string, helpLink *strin return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *ExecutableResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *ExecutableResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *ExecutableResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -6568,29 +6453,28 @@ func (s *ExecutableResource) WithEnvironmentCallback(callback func(...any) any) return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *ExecutableResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *ExecutableResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *ExecutableResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *ExecutableResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } @@ -10900,34 +10784,6 @@ func (s *ProjectResource) WithRequiredCommand(command string, helpLink *string) return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *ProjectResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *ProjectResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *ProjectResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -10943,29 +10799,28 @@ func (s *ProjectResource) WithEnvironmentCallback(callback func(...any) any) (*I return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *ProjectResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *ProjectResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *ProjectResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *ProjectResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } @@ -12935,34 +12790,6 @@ func (s *TestDatabaseResource) WithRequiredCommand(command string, helpLink *str return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *TestDatabaseResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *TestDatabaseResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *TestDatabaseResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -12978,29 +12805,28 @@ func (s *TestDatabaseResource) WithEnvironmentCallback(callback func(...any) any return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *TestDatabaseResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *TestDatabaseResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *TestDatabaseResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *TestDatabaseResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } @@ -14473,34 +14299,6 @@ func (s *TestRedisResource) WithRequiredCommand(command string, helpLink *string return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *TestRedisResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *TestRedisResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *TestRedisResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -14516,29 +14314,28 @@ func (s *TestRedisResource) WithEnvironmentCallback(callback func(...any) any) ( return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *TestRedisResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *TestRedisResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *TestRedisResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *TestRedisResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } @@ -16236,34 +16033,6 @@ func (s *TestVaultResource) WithRequiredCommand(command string, helpLink *string return result.(*IResource), nil } -// WithEnvironment sets an environment variable -func (s *TestVaultResource) WithEnvironment(name string, value string) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - -// WithEnvironmentExpression adds an environment variable with a reference expression -func (s *TestVaultResource) WithEnvironmentExpression(name string, value *ReferenceExpression) (*IResourceWithEnvironment, error) { - reqArgs := map[string]any{ - "builder": SerializeValue(s.Handle()), - } - reqArgs["name"] = SerializeValue(name) - reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs) - if err != nil { - return nil, err - } - return result.(*IResourceWithEnvironment), nil -} - // WithEnvironmentCallback sets environment variables via callback func (s *TestVaultResource) WithEnvironmentCallback(callback func(...any) any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -16279,29 +16048,28 @@ func (s *TestVaultResource) WithEnvironmentCallback(callback func(...any) any) ( return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentCallbackAsync sets environment variables via async callback -func (s *TestVaultResource) WithEnvironmentCallbackAsync(callback func(...any) any) (*IResourceWithEnvironment, error) { +// WithEnvironmentEndpoint sets an environment variable from an endpoint reference +func (s *TestVaultResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } - if callback != nil { - reqArgs["callback"] = RegisterCallback(callback) - } - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs) + reqArgs["name"] = SerializeValue(name) + reqArgs["endpointReference"] = SerializeValue(endpointReference) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) if err != nil { return nil, err } return result.(*IResourceWithEnvironment), nil } -// WithEnvironmentEndpoint sets an environment variable from an endpoint reference -func (s *TestVaultResource) WithEnvironmentEndpoint(name string, endpointReference *EndpointReference) (*IResourceWithEnvironment, error) { +// WithEnvironment sets an environment variable on the resource +func (s *TestVaultResource) WithEnvironment(name string, value any) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) - reqArgs["endpointReference"] = SerializeValue(endpointReference) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs) + reqArgs["value"] = SerializeValue(value) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withEnvironment", reqArgs) if err != nil { return nil, err } diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java index 0cb7675f7e1..0120e347841 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java @@ -718,24 +718,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -746,16 +728,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -765,6 +737,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); @@ -2601,24 +2582,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -2629,16 +2592,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -2648,6 +2601,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); @@ -3616,24 +3578,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -3644,16 +3588,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -3663,6 +3597,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); @@ -4664,24 +4607,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -4692,16 +4617,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -4711,6 +4626,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); @@ -7574,24 +7498,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -7602,16 +7508,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -7621,6 +7517,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); @@ -8934,24 +8839,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -8962,16 +8849,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -8981,6 +8858,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); @@ -9957,24 +9843,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -9985,16 +9853,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -10004,6 +9862,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); @@ -11137,24 +11004,6 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Sets an environment variable */ - public IResourceWithEnvironment withEnvironment(String name, String value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); - } - - /** Adds an environment variable with a reference expression */ - public IResourceWithEnvironment withEnvironmentExpression(String name, ReferenceExpression value) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - reqArgs.put("name", AspireClient.serializeValue(name)); - reqArgs.put("value", AspireClient.serializeValue(value)); - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentExpression", reqArgs); - } - /** Sets environment variables via callback */ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { Map reqArgs = new HashMap<>(); @@ -11165,16 +11014,6 @@ public IResourceWithEnvironment withEnvironmentCallback(Function callback) { - Map reqArgs = new HashMap<>(); - reqArgs.put("builder", AspireClient.serializeValue(getHandle())); - if (callback != null) { - reqArgs.put("callback", getClient().registerCallback(callback)); - } - return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentCallbackAsync", reqArgs); - } - /** Sets an environment variable from an endpoint reference */ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointReference endpointReference) { Map reqArgs = new HashMap<>(); @@ -11184,6 +11023,15 @@ public IResourceWithEnvironment withEnvironmentEndpoint(String name, EndpointRef return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentEndpoint", reqArgs); } + /** Sets an environment variable on the resource */ + public IResourceWithEnvironment withEnvironment(String name, Object value) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironment", reqArgs); + } + /** Sets an environment variable from a parameter resource */ public IResourceWithEnvironment withEnvironmentParameter(String name, ParameterResource parameter) { Map reqArgs = new HashMap<>(); diff --git a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py index e61b6a135c6..a79bac2a416 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py +++ b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py @@ -356,20 +356,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -378,14 +364,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -393,6 +371,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -1763,20 +1748,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -1785,14 +1756,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -1800,6 +1763,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -2508,20 +2478,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -2530,14 +2486,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -2545,6 +2493,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -3280,20 +3235,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -3302,14 +3243,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -3317,6 +3250,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -5457,20 +5397,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -5479,14 +5405,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -5494,6 +5412,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -6483,20 +6408,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -6505,14 +6416,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -6520,6 +6423,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7234,20 +7144,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7256,14 +7152,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7271,6 +7159,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -8111,20 +8006,6 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_environment(self, name: str, value: str) -> IResourceWithEnvironment: - """Sets an environment variable""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) - - def with_environment_expression(self, name: str, value: ReferenceExpression) -> IResourceWithEnvironment: - """Adds an environment variable with a reference expression""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - args["name"] = serialize_value(name) - args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args) - def with_environment_callback(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: """Sets environment variables via callback""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -8133,14 +8014,6 @@ def with_environment_callback(self, callback: Callable[[EnvironmentCallbackConte args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallback", args) - def with_environment_callback_async(self, callback: Callable[[EnvironmentCallbackContext], None]) -> IResourceWithEnvironment: - """Sets environment variables via async callback""" - args: Dict[str, Any] = { "builder": serialize_value(self._handle) } - callback_id = register_callback(callback) if callback is not None else None - if callback_id is not None: - args["callback"] = callback_id - return self._client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args) - def with_environment_endpoint(self, name: str, endpoint_reference: EndpointReference) -> IResourceWithEnvironment: """Sets an environment variable from an endpoint reference""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -8148,6 +8021,13 @@ def with_environment_endpoint(self, name: str, endpoint_reference: EndpointRefer args["endpointReference"] = serialize_value(endpoint_reference) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args) + def with_environment(self, name: str, value: str | ReferenceExpression | EndpointReference | ParameterResource | IResourceWithConnectionString) -> IResourceWithEnvironment: + """Sets an environment variable on the resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + return self._client.invoke_capability("Aspire.Hosting/withEnvironment", args) + def with_environment_parameter(self, name: str, parameter: ParameterResource) -> IResourceWithEnvironment: """Sets an environment variable from a parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } diff --git a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs index 8cf8e43dc67..b79ba11edd0 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs +++ b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs @@ -858,28 +858,6 @@ impl CSharpAppResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -891,24 +869,24 @@ impl CSharpAppResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -3149,28 +3127,6 @@ impl ContainerResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -3182,24 +3138,24 @@ impl ContainerResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -4457,28 +4413,6 @@ impl DotnetToolResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -4490,24 +4424,24 @@ impl DotnetToolResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -5745,28 +5679,6 @@ impl ExecutableResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -5778,24 +5690,24 @@ impl ExecutableResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -9747,28 +9659,6 @@ impl ProjectResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -9780,24 +9670,24 @@ impl ProjectResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -11516,28 +11406,6 @@ impl TestDatabaseResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -11549,24 +11417,24 @@ impl TestDatabaseResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -12752,28 +12620,6 @@ impl TestRedisResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -12785,24 +12631,24 @@ impl TestRedisResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } @@ -14161,28 +14007,6 @@ impl TestVaultResource { Ok(IResource::new(handle, self.client.clone())) } - /// Sets an environment variable - pub fn with_environment(&self, name: &str, value: &str) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - - /// Adds an environment variable with a reference expression - pub fn with_environment_expression(&self, name: &str, value: ReferenceExpression) -> Result> { - let mut args: HashMap = HashMap::new(); - args.insert("builder".to_string(), self.handle.to_json()); - args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentExpression", args)?; - let handle: Handle = serde_json::from_value(result)?; - Ok(IResourceWithEnvironment::new(handle, self.client.clone())) - } - /// Sets environment variables via callback pub fn with_environment_callback(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { let mut args: HashMap = HashMap::new(); @@ -14194,24 +14018,24 @@ impl TestVaultResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets environment variables via async callback - pub fn with_environment_callback_async(&self, callback: impl Fn(Vec) -> Value + Send + Sync + 'static) -> Result> { + /// Sets an environment variable from an endpoint reference + pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); - let callback_id = register_callback(callback); - args.insert("callback".to_string(), Value::String(callback_id)); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentCallbackAsync", args)?; + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Sets an environment variable from an endpoint reference - pub fn with_environment_endpoint(&self, name: &str, endpoint_reference: &EndpointReference) -> Result> { + /// Sets an environment variable on the resource + pub fn with_environment(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("endpointReference".to_string(), endpoint_reference.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withEnvironmentEndpoint", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withEnvironment", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt index 0682a945fa3..b287abc55c8 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt @@ -517,20 +517,6 @@ } ] }, - { - CapabilityId: Aspire.Hosting/withEnvironmentCallbackAsync, - MethodName: withEnvironmentCallbackAsync, - TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment, - IsInterface: true - }, - ExpandedTargetTypes: [ - { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false - } - ] - }, { CapabilityId: Aspire.Hosting/withEnvironmentConnectionString, MethodName: withEnvironmentConnectionString, @@ -559,20 +545,6 @@ } ] }, - { - CapabilityId: Aspire.Hosting/withEnvironmentExpression, - MethodName: withEnvironmentExpression, - TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment, - IsInterface: true - }, - ExpandedTargetTypes: [ - { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false - } - ] - }, { CapabilityId: Aspire.Hosting/withEnvironmentParameter, MethodName: withEnvironmentParameter, diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts index 7062cbbf735..11d33822cad 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts @@ -6843,41 +6843,11 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -6888,43 +6858,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -8237,31 +8202,21 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -8761,41 +8716,11 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -8806,43 +8731,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -10081,31 +10001,21 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -10708,41 +10618,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -10753,43 +10633,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -12048,31 +11923,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -12580,41 +12445,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -12625,43 +12460,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -13890,31 +13720,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -16171,41 +15991,11 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -16216,43 +16006,38 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -17491,31 +17276,21 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -18226,41 +18001,11 @@ export class TestDatabaseResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new TestDatabaseResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -18271,43 +18016,38 @@ export class TestDatabaseResource extends ResourceBuilderBase Promise): TestDatabaseResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -19620,31 +19360,21 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): TestDatabaseResourcePromise { - return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -20355,41 +20085,11 @@ export class TestRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new TestRedisResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -20400,43 +20100,38 @@ export class TestRedisResource extends ResourceBuilderBase Promise): TestRedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -21977,31 +21672,21 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): TestRedisResourcePromise { - return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -22792,41 +22477,11 @@ export class TestVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new TestVaultResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -22837,43 +22492,38 @@ export class TestVaultResource extends ResourceBuilderBase Promise): TestVaultResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new TestVaultResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new TestVaultResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -24201,31 +23851,21 @@ export class TestVaultResourcePromise implements PromiseLike return new TestVaultResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): TestVaultResourcePromise { - return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -26207,41 +25847,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -26252,43 +25862,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -26511,31 +26116,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); From 860cf9c47c453e20e865cbf94965511c922d7d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Wed, 18 Mar 2026 15:17:58 -0700 Subject: [PATCH 06/49] Add TypeScript SDK refresh workflow (#15299) * Add TypeScript SDK refresh workflow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address TypeScript SDK workflow review comments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/refresh-typescript-sdks.yml | 45 ++++++ eng/refreshTypeScriptSdks.ps1 | 152 ++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 .github/workflows/refresh-typescript-sdks.yml create mode 100644 eng/refreshTypeScriptSdks.ps1 diff --git a/.github/workflows/refresh-typescript-sdks.yml b/.github/workflows/refresh-typescript-sdks.yml new file mode 100644 index 00000000000..deadec5638d --- /dev/null +++ b/.github/workflows/refresh-typescript-sdks.yml @@ -0,0 +1,45 @@ +name: Refresh TypeScript Playground SDKs + +on: + workflow_dispatch: + schedule: + - cron: '0 16 * * *' # 8am PT / 16:00 UTC - same schedule as manifest refresh + +permissions: + contents: write + pull-requests: write + +jobs: + generate-and-pr: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'dotnet' }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4 + with: + global-json-file: global.json + + - name: Setup Node.js + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 + with: + node-version: 20.x + + - name: Run refreshTypeScriptSdks script + shell: pwsh + run: | + ./eng/refreshTypeScriptSdks.ps1 + + - name: Create or update pull request + uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: update-typescript-playground-sdks + base: main + commit-message: "[Automated] Update TypeScript Playground AppHost SDKs" + labels: | + area-app-model + area-engineering-systems + title: "[Automated] Update TypeScript Playground AppHost SDKs" + body: "Auto-generated update to refresh the TypeScript playground AppHost SDKs." diff --git a/eng/refreshTypeScriptSdks.ps1 b/eng/refreshTypeScriptSdks.ps1 new file mode 100644 index 00000000000..1d780c1d39d --- /dev/null +++ b/eng/refreshTypeScriptSdks.ps1 @@ -0,0 +1,152 @@ +#!/usr/bin/env pwsh + +[CmdletBinding()] +param( + [string]$AppPattern = '*' +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + +$scriptDir = $PSScriptRoot +$repoRoot = Split-Path -Parent $scriptDir +$playgroundRoot = Join-Path -Path $repoRoot -ChildPath 'playground/polyglot/TypeScript' +$cliProject = Join-Path -Path $repoRoot -ChildPath 'src/Aspire.Cli/Aspire.Cli.csproj' +$requiredGeneratedFiles = @('aspire.ts', 'base.ts', 'transport.ts') + +function Invoke-RepoRestore { + if ($IsWindows -or $env:OS -eq 'Windows_NT') { + & (Join-Path $repoRoot 'restore.cmd') + } + else { + & (Join-Path $repoRoot 'restore.sh') + } +} + +function Get-ValidationAppHosts { + if (-not (Test-Path $playgroundRoot)) { + throw "TypeScript playground directory not found at '$playgroundRoot'." + } + + $appHosts = foreach ($integrationDir in Get-ChildItem -Path $playgroundRoot -Directory | Sort-Object Name) { + if ($integrationDir.Name -notlike $AppPattern) { + continue + } + + $appHostDir = Join-Path $integrationDir.FullName 'ValidationAppHost' + $appHostEntryPoint = Join-Path $appHostDir 'apphost.ts' + if (Test-Path $appHostEntryPoint) { + Get-Item $appHostDir + } + } + + if (@($appHosts).Count -eq 0) { + throw "No TypeScript playground ValidationAppHost directories matched '$AppPattern'." + } + + return @($appHosts) +} + +function Install-NodeDependencies([string]$appDir) { + Push-Location $appDir + try { + $packageLockPath = Join-Path $appDir 'package-lock.json' + if (Test-Path $packageLockPath) { + & npm ci --ignore-scripts --no-audit --no-fund + } + else { + & npm install --ignore-scripts --no-audit --no-fund + } + } + finally { + Pop-Location + } +} + +function Assert-GeneratedSdkFiles([string]$appDir) { + $generatedDir = Join-Path $appDir '.modules' + foreach ($file in $requiredGeneratedFiles) { + $path = Join-Path $generatedDir $file + if (-not (Test-Path $path)) { + throw "Expected generated SDK file '$path' was not created." + } + } +} + +if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) { + throw "The .NET SDK was not found in PATH." +} + +if (-not (Get-Command npm -ErrorAction SilentlyContinue)) { + throw "npm was not found in PATH." +} + +Write-Host '=== Refreshing TypeScript playground SDKs ===' +Write-Host "Playground root: $playgroundRoot" +Write-Host "CLI project: $cliProject" + +Invoke-RepoRestore + +& dotnet build $cliProject /p:SkipNativeBuild=true + +$appHosts = Get-ValidationAppHosts +Write-Host "Found $($appHosts.Count) TypeScript playground apps matching '$AppPattern'." + +$failures = [System.Collections.Generic.List[string]]::new() +$updated = [System.Collections.Generic.List[string]]::new() + +foreach ($appHost in $appHosts) { + $appName = '{0}/{1}' -f (Split-Path -Path $appHost.FullName -Parent | Split-Path -Leaf), $appHost.Name + + Write-Host '' + Write-Host '----------------------------------------' + Write-Host "Refreshing: $appName" + Write-Host '----------------------------------------' + + Push-Location $appHost.FullName + try { + Write-Host ' -> Installing npm dependencies...' + Install-NodeDependencies -appDir $appHost.FullName + + $generatedDir = Join-Path $appHost.FullName '.modules' + if (Test-Path $generatedDir) { + Write-Host ' -> Clearing existing generated SDK...' + Remove-Item -Path $generatedDir -Recurse -Force + } + + Write-Host ' -> Running aspire restore...' + & dotnet run --no-build --project $cliProject -- restore + + Write-Host ' -> Verifying generated SDK...' + Assert-GeneratedSdkFiles -appDir $appHost.FullName + + Write-Host " OK $appName refreshed" + $updated.Add($appName) + } + catch { + Write-Host " ERROR failed to refresh $appName" + Write-Host ($_ | Out-String) + $failures.Add($appName) + } + finally { + Pop-Location + } +} + +Write-Host '' +Write-Host '----------------------------------------' +Write-Host "Results: $($updated.Count) refreshed, $($failures.Count) failed out of $($appHosts.Count) apps" +Write-Host '----------------------------------------' + +if ($failures.Count -gt 0) { + Write-Host '' + Write-Host 'Failed apps:' + foreach ($failure in $failures) { + Write-Host " - $failure" + } + + exit 1 +} + +Write-Host 'All TypeScript playground SDKs refreshed successfully.' From 5da0723bff448ec7673e8f0b7ce4cfca82728fa7 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 18 Mar 2026 21:13:51 -0400 Subject: [PATCH 07/49] [release/13.2] Fix Homebrew and WinGet publishing for stable artifact versions (#15367) * Add installer paths to CI trigger patterns * Replace channel with artifactVersion in Homebrew cask generation Stable builds publish CLI archives under a preview version path on ci.dot.net (e.g. aspire/9.2.0-preview.1.12345/) while the tarball filename uses the real stable version (aspire-cli-osx-arm64-9.2.0.tar.gz). The old code assumed the same version appeared in both the URL path and filename. Introduce --artifact-version to generate-cask.sh so the URL path segment and the filename version can differ. Add --archive-root for computing SHA256 hashes from locally-built archives instead of downloading from ci.dot.net. Remove the --channel parameter and the separate aspire@prerelease.rb.template; only the stable aspire.rb template is used. Simplify dogfood.sh accordingly. * Harden Homebrew prepare-stage validation Add brew style --fix to auto-correct formatting before auditing. Detect whether the cask is new upstream by querying the GitHub API and run brew audit with --new when appropriate. Use HOMEBREW_NO_INSTALL_FROM_API=1 during install tests to ensure the local tap cask is used rather than the Homebrew API cache. Add proper cleanup traps for brew untap on exit. Make the install/uninstall test conditional via a runInstallTest parameter. Write a validation-summary.json artifact recording all check results so the publish step can verify that prepare-stage validation actually ran and passed. * Rewrite Homebrew publish to use GitHub REST and GraphQL API Replace the gh CLI and git clone/push workflow with pure GitHub API calls via Invoke-RestMethod. This removes the need for a git installation on the build agent and avoids fork-clone race conditions. Key changes: - Fork Homebrew/homebrew-cask via API with polling for readiness - Create/reset the PR branch and upload the cask file via the contents API - Check whether upstream already has the exact same content and skip if so - Require a passing validation-summary.json before submitting - Create PRs as drafts; convert existing open PRs to draft via GraphQL - Generate a rich PR body with a checklist of all validation steps - Reference superseded closed PRs in the body when re-submitting * Improve WinGet manifest generation and publishing Apply the same artifactVersion split to the WinGet pipeline: the installer URL path uses the artifact version while the package version uses the real stable version. Update generate-manifests.ps1 and the prepare/publish templates accordingly. * Wire up artifactVersion in release and CI pipelines Update the top-level pipeline files to pass artifactVersion instead of channel to the Homebrew and WinGet templates. Add the new installer preparation and publishing stages to the unofficial pipeline. * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Address installer publishing review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * [release/13.2] Fix Homebrew publish URI escaping Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/homebrew/README.md | 37 +- eng/homebrew/aspire.rb.template | 10 +- eng/homebrew/aspire@prerelease.rb.template | 19 - eng/homebrew/dogfood.sh | 60 +-- eng/homebrew/generate-cask.sh | 95 +++- eng/pipelines/azure-pipelines-unofficial.yml | 137 ++++++ eng/pipelines/azure-pipelines.yml | 51 ++- eng/pipelines/release-publish-nuget.yml | 246 +++++----- .../templates/prepare-homebrew-cask.yml | 201 +++++--- .../templates/prepare-winget-manifest.yml | 38 +- eng/pipelines/templates/publish-homebrew.yml | 430 +++++++++++++++--- eng/pipelines/templates/publish-winget.yml | 57 ++- eng/testing/github-ci-trigger-patterns.txt | 2 + eng/winget/README.md | 2 +- eng/winget/generate-manifests.ps1 | 81 +++- 15 files changed, 1114 insertions(+), 352 deletions(-) delete mode 100644 eng/homebrew/aspire@prerelease.rb.template diff --git a/eng/homebrew/README.md b/eng/homebrew/README.md index 44b3ec4d7a0..0f5bf88c142 100644 --- a/eng/homebrew/README.md +++ b/eng/homebrew/README.md @@ -8,7 +8,6 @@ Aspire CLI is distributed via [Homebrew Cask](https://docs.brew.sh/Cask-Cookbook ```bash brew install --cask aspire # stable -# brew install --cask aspire@prerelease # preview (not yet supported) ``` ## Contents @@ -16,14 +15,13 @@ brew install --cask aspire # stable | File | Description | |---|---| | `aspire.rb.template` | Cask template for stable releases | -| `aspire@prerelease.rb.template` | Cask template for prerelease builds | | `generate-cask.sh` | Downloads tarballs, computes SHA256 hashes, generates cask from template | ### Pipeline templates | File | Description | |---|---| -| `eng/pipelines/templates/prepare-homebrew-cask.yml` | Generates, validates, audits, and tests the cask | +| `eng/pipelines/templates/prepare-homebrew-cask.yml` | Generates, styles, validates, audits, and tests the cask | | `eng/pipelines/templates/publish-homebrew.yml` | Submits the cask as a PR to `Homebrew/homebrew-cask` | ## Supported Platforms @@ -33,22 +31,22 @@ macOS only (arm64, x64). The cask uses `arch arm: "arm64", intel: "x64"` for URL ## Artifact URLs ```text -https://ci.dot.net/public/aspire/{VERSION}/aspire-cli-osx-{arch}-{VERSION}.tar.gz +https://ci.dot.net/public/aspire/{ARTIFACT_VERSION}/aspire-cli-osx-{arch}-{VERSION}.tar.gz ``` Where arch is `arm64` or `x64`. ## Why Cask -| Product | Type | Install command | Preview channel | -|---|---|---|---| -| GitHub Copilot CLI | homebrew-cask | `brew install --cask copilot-cli` | `copilot-cli@prerelease` | -| .NET SDK | homebrew-cask | `brew install --cask dotnet-sdk` | `dotnet-sdk@preview` | -| PowerShell | homebrew-cask | `brew install --cask powershell` | `powershell@preview` | +| Product | Type | Install command | +|---|---|---| +| GitHub Copilot CLI | homebrew-cask | `brew install --cask copilot-cli` | +| .NET SDK | homebrew-cask | `brew install --cask dotnet-sdk` | +| PowerShell | homebrew-cask | `brew install --cask powershell` | - **URL templating**: `url "...osx-#{arch}-#{version}.tar.gz"` — a single line instead of nested `on_macos do / if Hardware::CPU.arm?` blocks - **Official repo path**: Casks can be submitted to `Homebrew/homebrew-cask` for `brew install aspire` without a tap -- **Cleaner multi-channel**: `aspire` and `aspire@prerelease` follow established cask naming conventions +- **Stable-only release flow**: the current Aspire Homebrew publishing pipeline prepares and submits only the stable `aspire` cask, while a separate prerelease cask remains a possible future option ## CI Pipeline @@ -57,17 +55,26 @@ Where arch is `arm64` or `x64`. | `azure-pipelines.yml` (prepare stage) | Stable casks (artifacts only) | — | | `release-publish-nuget.yml` (release) | — | Stable cask only | -Publishing submits a PR to `Homebrew/homebrew-cask` using `gh pr create`: +Publishing submits a PR to `Homebrew/homebrew-cask` using the GitHub REST API: 1. Forks `Homebrew/homebrew-cask` (idempotent — reuses existing fork) -2. Creates a branch named `aspire-{version}` -3. Copies the generated cask to `Casks/a/aspire.rb` (or `aspire@prerelease.rb`) -4. Pushes and opens a PR with title `aspire {version}` +2. Creates or resets a branch named `aspire-{version}` +3. Copies the generated cask to `Casks/a/aspire.rb` +4. Reuses the existing open PR for that branch when present +5. Force-pushes the same branch for reruns; if prior PRs from that branch were closed, the publish step opens a fresh PR and marks the old ones as superseded +6. Opens a PR with title `aspire {version}` when none exists + +Prepare validation currently runs: + +1. `ruby -c` for syntax validation +2. `brew style --fix` on the generated cask +3. `brew audit --cask --online`, or `brew audit --cask --new --online` when the cask does not yet exist upstream +4. `HOMEBREW_NO_INSTALL_FROM_API=1 brew install --cask ...` followed by uninstall validation ## Open Items - [ ] Submit initial `aspire` cask PR to `Homebrew/homebrew-cask` for acceptance -- [ ] Submit `aspire@prerelease` cask PR to `Homebrew/homebrew-cask` +- [ ] (Future) Decide whether to add a separate prerelease cask (for example, `aspire@prerelease`) and update pipelines/docs accordingly - [ ] Configure `aspire-homebrew-bot-pat` secret in the pipeline variable group ## References diff --git a/eng/homebrew/aspire.rb.template b/eng/homebrew/aspire.rb.template index 5c749689faa..dbe07554fe3 100644 --- a/eng/homebrew/aspire.rb.template +++ b/eng/homebrew/aspire.rb.template @@ -2,17 +2,15 @@ cask "aspire" do arch arm: "arm64", intel: "x64" version "${VERSION}" - sha256 arm: "${SHA256_OSX_ARM64}", - intel: "${SHA256_OSX_X64}" + sha256 arm: "${SHA256_OSX_ARM64}", + intel: "${SHA256_OSX_X64}" - url "https://ci.dot.net/public/aspire/#{version}/aspire-cli-osx-#{arch}-#{version}.tar.gz", + url "https://ci.dot.net/public/aspire/${ARTIFACT_VERSION}/aspire-cli-osx-#{arch}-#{version}.tar.gz", verified: "ci.dot.net/public/aspire/" name "Aspire CLI" - desc "CLI tool for building observable, production-ready distributed applications with Aspire" + desc "CLI for building observable, production-ready distributed applications" homepage "https://aspire.dev/" - conflicts_with cask: "aspire@prerelease" - binary "aspire" zap trash: "~/.aspire" diff --git a/eng/homebrew/aspire@prerelease.rb.template b/eng/homebrew/aspire@prerelease.rb.template deleted file mode 100644 index ebb0f45a0ad..00000000000 --- a/eng/homebrew/aspire@prerelease.rb.template +++ /dev/null @@ -1,19 +0,0 @@ -cask "aspire@prerelease" do - arch arm: "arm64", intel: "x64" - - version "${VERSION}" - sha256 arm: "${SHA256_OSX_ARM64}", - intel: "${SHA256_OSX_X64}" - - url "https://ci.dot.net/public/aspire/#{version}/aspire-cli-osx-#{arch}-#{version}.tar.gz", - verified: "ci.dot.net/public/aspire/" - name "Aspire CLI (Prerelease)" - desc "CLI tool for building observable, production-ready distributed applications with Aspire" - homepage "https://aspire.dev/" - - conflicts_with cask: "aspire" - - binary "aspire" - - zap trash: "~/.aspire" -end diff --git a/eng/homebrew/dogfood.sh b/eng/homebrew/dogfood.sh index 8d0a44601a5..fbe7ac44689 100755 --- a/eng/homebrew/dogfood.sh +++ b/eng/homebrew/dogfood.sh @@ -33,17 +33,20 @@ EOF exit 0 } +is_cask_installed() { + local caskName="$1" + + brew list --cask --versions 2>/dev/null | awk '{print $1}' | grep -Fx -- "$caskName" >/dev/null +} + uninstall() { echo "Uninstalling dogfooded Aspire CLI..." - # Determine which cask is installed - for caskName in "aspire" "aspire@prerelease"; do - if brew list --cask "$TAP_NAME/$caskName" &>/dev/null; then - echo " Uninstalling $TAP_NAME/$caskName..." - brew uninstall --cask "$TAP_NAME/$caskName" - echo " Uninstalled." - fi - done + if brew list --cask "$TAP_NAME/aspire" &>/dev/null; then + echo " Uninstalling $TAP_NAME/aspire..." + brew uninstall --cask "$TAP_NAME/aspire" + echo " Uninstalled." + fi if brew tap-info "$TAP_NAME" &>/dev/null; then echo " Removing tap $TAP_NAME..." @@ -74,16 +77,14 @@ fi # Auto-detect cask file if not specified if [[ -z "$CASK_FILE" ]]; then - for candidate in "$SCRIPT_DIR/aspire.rb" "$SCRIPT_DIR/aspire@prerelease.rb"; do - if [[ -f "$candidate" ]]; then - CASK_FILE="$candidate" - break - fi - done + candidate="$SCRIPT_DIR/aspire.rb" + if [[ -f "$candidate" ]]; then + CASK_FILE="$candidate" + fi if [[ -z "$CASK_FILE" ]]; then echo "Error: No cask file found in $SCRIPT_DIR" - echo "Expected aspire.rb or aspire@prerelease.rb" + echo "Expected aspire.rb" exit 1 fi fi @@ -97,20 +98,24 @@ CASK_FILE="$(cd "$(dirname "$CASK_FILE")" && pwd)/$(basename "$CASK_FILE")" CASK_FILENAME="$(basename "$CASK_FILE")" CASK_NAME="${CASK_FILENAME%.rb}" +if [[ "$CASK_NAME" != "aspire" ]]; then + echo "Error: Only the stable Homebrew cask is supported." + echo "Expected aspire.rb" + exit 1 +fi + echo "Aspire CLI Homebrew Dogfood Installer" echo "======================================" echo " Cask file: $CASK_FILE" echo " Cask name: $CASK_NAME" echo "" -# Check for conflicts with official installs -for check in "aspire" "aspire@prerelease"; do - if brew list --cask "$check" &>/dev/null; then - echo "Error: '$check' is already installed from the official Homebrew tap." - echo "Uninstall it first with: brew uninstall --cask $check" - exit 1 - fi -done +if is_cask_installed "aspire"; then + echo "Error: 'aspire' is already installed." + echo "If this is a previous dogfood install, remove it with: $(basename "$0") --uninstall" + echo "Otherwise uninstall it first with: brew uninstall --cask aspire" + exit 1 +fi # Check for leftover local/aspire tap from pipeline testing if brew tap-info "local/aspire" &>/dev/null 2>&1; then @@ -128,12 +133,9 @@ fi # Clean up any previous dogfood tap if brew tap-info "$TAP_NAME" &>/dev/null 2>&1; then echo "Removing previous dogfood tap..." - # Uninstall any casks from the old tap first - for old in "aspire" "aspire@prerelease"; do - if brew list --cask "$TAP_NAME/$old" &>/dev/null; then - brew uninstall --cask "$TAP_NAME/$old" || true - fi - done + if is_cask_installed "aspire"; then + brew uninstall --cask "aspire" || true + fi brew untap "$TAP_NAME" fi diff --git a/eng/homebrew/generate-cask.sh b/eng/homebrew/generate-cask.sh index 906bed34da3..53727c781f3 100755 --- a/eng/homebrew/generate-cask.sh +++ b/eng/homebrew/generate-cask.sh @@ -7,14 +7,15 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" usage() { cat <&2 + echo " Path: $file_path" >&2 + + local hash + hash="$(shasum -a 256 "$file_path" | awk '{print $1}')" + echo " SHA256: $hash" >&2 + echo "$hash" +} + +find_local_archive() { + local archive_name="$1" + local archive_path + local matches=() + local match + + while IFS= read -r archive_path; do + matches+=("$archive_path") + done < <(find "$ARCHIVE_ROOT" -type f -name "$archive_name" -print | LC_ALL=C sort) + + if [[ "${#matches[@]}" -eq 0 ]]; then + echo "Error: Could not find local archive '$archive_name' under '$ARCHIVE_ROOT'" >&2 + exit 1 + fi + + if [[ "${#matches[@]}" -gt 1 ]]; then + echo "Error: Found multiple local archives named '$archive_name' under '$ARCHIVE_ROOT':" >&2 + for match in "${matches[@]}"; do + echo " $match" >&2 + done + exit 1 + fi + + echo "${matches[0]}" +} + # Check if a URL is accessible (HEAD request) url_exists() { curl -o /dev/null -s --head --fail "$1" } -echo "Generating Homebrew cask for Aspire version $VERSION (channel: $CHANNEL)" +echo "Generating Homebrew cask for Aspire version $VERSION" echo "" # macOS tarballs are required OSX_ARM64_URL="$BASE_URL/aspire-cli-osx-arm64-$VERSION.tar.gz" OSX_X64_URL="$BASE_URL/aspire-cli-osx-x64-$VERSION.tar.gz" +if [[ -n "$ARCHIVE_ROOT" && ! -d "$ARCHIVE_ROOT" ]]; then + echo "Error: --archive-root directory does not exist: $ARCHIVE_ROOT" + exit 1 +fi + # Validate URLs are accessible before downloading (fast-fail) if [[ "$VALIDATE_URLS" == true ]]; then echo "Validating tarball URLs..." @@ -115,8 +155,16 @@ if [[ "$VALIDATE_URLS" == true ]]; then echo "" fi -SHA256_OSX_ARM64="$(compute_sha256 "$OSX_ARM64_URL" "macOS ARM64 tarball")" -SHA256_OSX_X64="$(compute_sha256 "$OSX_X64_URL" "macOS x64 tarball")" +if [[ -n "$ARCHIVE_ROOT" ]]; then + OSX_ARM64_ARCHIVE="$(find_local_archive "aspire-cli-osx-arm64-$VERSION.tar.gz")" + OSX_X64_ARCHIVE="$(find_local_archive "aspire-cli-osx-x64-$VERSION.tar.gz")" + + SHA256_OSX_ARM64="$(compute_sha256_from_file "$OSX_ARM64_ARCHIVE" "macOS ARM64 tarball")" + SHA256_OSX_X64="$(compute_sha256_from_file "$OSX_X64_ARCHIVE" "macOS x64 tarball")" +else + SHA256_OSX_ARM64="$(compute_sha256 "$OSX_ARM64_URL" "macOS ARM64 tarball")" + SHA256_OSX_X64="$(compute_sha256 "$OSX_X64_URL" "macOS x64 tarball")" +fi echo "" echo "Generating cask from template..." @@ -124,6 +172,7 @@ echo "Generating cask from template..." # Read template and perform substitutions content="$(cat "$TEMPLATE")" content="${content//\$\{VERSION\}/$VERSION}" +content="${content//\$\{ARTIFACT_VERSION\}/$ARTIFACT_VERSION}" content="${content//\$\{SHA256_OSX_ARM64\}/$SHA256_OSX_ARM64}" content="${content//\$\{SHA256_OSX_X64\}/$SHA256_OSX_X64}" diff --git a/eng/pipelines/azure-pipelines-unofficial.yml b/eng/pipelines/azure-pipelines-unofficial.yml index e4147cdf65d..44a7668ba1e 100644 --- a/eng/pipelines/azure-pipelines-unofficial.yml +++ b/eng/pipelines/azure-pipelines-unofficial.yml @@ -145,6 +145,7 @@ extends: preSteps: - checkout: self fetchDepth: 1 + clean: true steps: - task: DownloadPipelineArtifact@2 @@ -208,3 +209,139 @@ extends: targetRids: - win-x64 - win-arm64 + - pwsh: | + $ErrorActionPreference = 'Stop' + $shippingDir = "$(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/Shipping" + $nupkg = Get-ChildItem -Path $shippingDir -Filter "Aspire.Hosting.AppHost.*.nupkg" -ErrorAction SilentlyContinue | + Where-Object { $_.Name -notmatch '\.symbols\.' } | + Select-Object -First 1 + + if (-not $nupkg) { + Write-Error "Could not find Aspire.Hosting.AppHost nupkg in $shippingDir" + exit 1 + } + + $version = $nupkg.Name -replace '^Aspire\.Hosting\.AppHost\.', '' -replace '\.nupkg$', '' + + if ($version -notmatch '^\d+\.\d+\.\d+') { + Write-Error "Extracted version '$version' does not look like a valid semver. Check the nupkg name." + exit 1 + } + + Write-Host "Detected Aspire version: $version (from $($nupkg.Name))" + Write-Host "##vso[task.setvariable variable=aspireVersion;isOutput=true]$version" + name: computeVersion + displayName: 🟣Compute Aspire version from nupkg + + - pwsh: | + $ErrorActionPreference = 'Stop' + $artifactVersion = dotnet msbuild "$(Build.SourcesDirectory)/src/Aspire.Dashboard/Aspire.Dashboard.csproj" -getProperty:PackageVersion -property:SuppressFinalPackageVersion=true -property:OfficialBuildId=$(BUILD.BUILDNUMBER) + $artifactVersion = $artifactVersion.Trim() + + if ($artifactVersion -notmatch '^\d+\.\d+\.\d+') { + Write-Error "Computed artifact version '$artifactVersion' does not look like a valid semver. Check PackageVersion evaluation." + exit 1 + } + + Write-Host "Detected installer artifact version: $artifactVersion" + Write-Host "##vso[task.setvariable variable=aspireArtifactVersion;isOutput=true]$artifactVersion" + name: computeArtifactVersion + displayName: 🟣Compute installer artifact version + + - pwsh: | + $ErrorActionPreference = 'Stop' + $versionKind = dotnet msbuild "$(Build.SourcesDirectory)/eng/Versions.props" -getProperty:DotNetFinalVersionKind + $versionKind = $versionKind.Trim() + Write-Host "DotNetFinalVersionKind: '$versionKind'" + + if ($versionKind -eq 'release') { + $channel = 'stable' + } else { + $channel = 'prerelease' + } + + Write-Host "Installer channel: $channel" + Write-Host "##vso[task.setvariable variable=installerChannel;isOutput=true]$channel" + name: computeChannel + displayName: 🟣Determine installer channel + + - stage: prepare_installers + displayName: Prepare Installers + dependsOn: + - build + variables: + aspireVersion: $[ stageDependencies.build.Windows.outputs['computeVersion.aspireVersion'] ] + aspireArtifactVersion: $[ stageDependencies.build.Windows.outputs['computeArtifactVersion.aspireArtifactVersion'] ] + installerChannel: $[ stageDependencies.build.Windows.outputs['computeChannel.installerChannel'] ] + condition: | + and( + succeeded(), + ne(variables['Build.Reason'], 'PullRequest'), + or( + ne(dependencies.build.outputs['Windows.computeChannel.installerChannel'], 'stable'), + or( + eq(variables['Build.SourceBranch'], 'refs/heads/main'), + startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') + ) + ) + ) + jobs: + - template: /eng/common/templates-official/jobs/jobs.yml@self + parameters: + enableMicrobuild: false + enablePublishUsingPipelines: false + enablePublishBuildAssets: false + enablePublishBuildArtifacts: true + enableTelemetry: true + workspace: + clean: all + jobs: + - job: WinGet + displayName: WinGet Manifest + timeoutInMinutes: 30 + pool: + name: NetCore1ESPool-Internal + image: 1es-windows-2022 + os: windows + steps: + - checkout: self + fetchDepth: 1 + - task: DownloadPipelineArtifact@2 + displayName: 🟣Download CLI archives + inputs: + itemPattern: | + **/aspire-cli-*.zip + targetPath: '$(Pipeline.Workspace)/native-archives' + - template: /eng/pipelines/templates/prepare-winget-manifest.yml@self + parameters: + version: $(aspireVersion) + artifactVersion: $(aspireArtifactVersion) + channel: $(installerChannel) + archiveRoot: $(Pipeline.Workspace)/native-archives + validateUrls: false + runInstallTest: false + + - job: Homebrew + displayName: Homebrew Cask + timeoutInMinutes: 30 + condition: and(succeeded(), eq(variables['installerChannel'], 'stable')) + pool: + name: Azure Pipelines + vmImage: macOS-latest-internal + os: macOS + steps: + - checkout: self + fetchDepth: 1 + - task: DownloadPipelineArtifact@2 + displayName: 🟣Download CLI archives + inputs: + itemPattern: | + **/aspire-cli-*.tar.gz + targetPath: '$(Pipeline.Workspace)/native-archives' + - template: /eng/pipelines/templates/prepare-homebrew-cask.yml@self + parameters: + version: $(aspireVersion) + artifactVersion: $(aspireArtifactVersion) + archiveRoot: $(Pipeline.Workspace)/native-archives + validateUrls: false + runInstallTest: false diff --git a/eng/pipelines/azure-pipelines.yml b/eng/pipelines/azure-pipelines.yml index 75d22b26e68..5850f2ee702 100644 --- a/eng/pipelines/azure-pipelines.yml +++ b/eng/pipelines/azure-pipelines.yml @@ -225,6 +225,7 @@ extends: preSteps: - checkout: self fetchDepth: 1 + clean: true steps: - task: DownloadPipelineArtifact@2 @@ -293,23 +294,22 @@ extends: vscePublishPreRelease: ${{ parameters.vscePublishPreRelease }} # Extract the Aspire version from a generated nupkg filename so downstream - # stages (e.g. publish_winget) can use it. We use Aspire.Hosting.Docker - # because it has no RID in its filename, so stripping the prefix cleanly - # yields just the version (e.g. "13.2.0-preview.1.26074.3"). + # stages can use it. Aspire.Hosting.AppHost has no RID in its filename and + # does not suppress final package version stabilization, so stripping the + # prefix cleanly yields the stable version for installer publishing. - pwsh: | $ErrorActionPreference = 'Stop' $shippingDir = "$(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/Shipping" - $nupkg = Get-ChildItem -Path $shippingDir -Filter "Aspire.Hosting.Docker.*.nupkg" -ErrorAction SilentlyContinue | + $nupkg = Get-ChildItem -Path $shippingDir -Filter "Aspire.Hosting.AppHost.*.nupkg" -ErrorAction SilentlyContinue | Where-Object { $_.Name -notmatch '\.symbols\.' } | Select-Object -First 1 if (-not $nupkg) { - Write-Error "Could not find Aspire.Hosting.Docker nupkg in $shippingDir" + Write-Error "Could not find Aspire.Hosting.AppHost nupkg in $shippingDir" exit 1 } - # Extract version: strip the known prefix and .nupkg suffix - $version = $nupkg.Name -replace '^Aspire\.Hosting\.Docker\.', '' -replace '\.nupkg$', '' + $version = $nupkg.Name -replace '^Aspire\.Hosting\.AppHost\.', '' -replace '\.nupkg$', '' if ($version -notmatch '^\d+\.\d+\.\d+') { Write-Error "Extracted version '$version' does not look like a valid semver. Check the nupkg name." @@ -321,8 +321,22 @@ extends: name: computeVersion displayName: 🟣Compute Aspire version from nupkg - # Determine stable vs prerelease for installer pipelines (WinGet, Homebrew). - # DotNetFinalVersionKind is 'release' for stable builds, empty otherwise. + - pwsh: | + $ErrorActionPreference = 'Stop' + $artifactVersion = dotnet msbuild "$(Build.SourcesDirectory)/src/Aspire.Dashboard/Aspire.Dashboard.csproj" -getProperty:PackageVersion -property:SuppressFinalPackageVersion=true -property:OfficialBuildId=$(BUILD.BUILDNUMBER) + $artifactVersion = $artifactVersion.Trim() + + if ($artifactVersion -notmatch '^\d+\.\d+\.\d+') { + Write-Error "Computed artifact version '$artifactVersion' does not look like a valid semver. Check PackageVersion evaluation." + exit 1 + } + + Write-Host "Detected installer artifact version: $artifactVersion" + Write-Host "##vso[task.setvariable variable=aspireArtifactVersion;isOutput=true]$artifactVersion" + name: computeArtifactVersion + displayName: 🟣Compute installer artifact version + + # Determine stable vs prerelease for installer pipelines. - pwsh: | $ErrorActionPreference = 'Stop' $versionKind = dotnet msbuild "$(Build.SourcesDirectory)/eng/Versions.props" -getProperty:DotNetFinalVersionKind @@ -350,7 +364,6 @@ extends: # ---------------------------------------------------------------- # Generate and test installer packages (WinGet + Homebrew). - # Channel (stable/prerelease) is determined by the build stage. # Artifacts are consumed by release-publish-nuget.yml for stable # publishing. No publishing happens from this pipeline. # ---------------------------------------------------------------- @@ -360,8 +373,20 @@ extends: - build variables: aspireVersion: $[ stageDependencies.build.Windows.outputs['computeVersion.aspireVersion'] ] + aspireArtifactVersion: $[ stageDependencies.build.Windows.outputs['computeArtifactVersion.aspireArtifactVersion'] ] installerChannel: $[ stageDependencies.build.Windows.outputs['computeChannel.installerChannel'] ] - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + condition: | + and( + succeeded(), + ne(variables['Build.Reason'], 'PullRequest'), + or( + ne(dependencies.build.outputs['Windows.computeChannel.installerChannel'], 'stable'), + or( + eq(variables['Build.SourceBranch'], 'refs/heads/main'), + startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') + ) + ) + ) jobs: - template: /eng/common/templates-official/jobs/jobs.yml@self parameters: @@ -386,11 +411,13 @@ extends: - template: /eng/pipelines/templates/prepare-winget-manifest.yml@self parameters: version: $(aspireVersion) + artifactVersion: $(aspireArtifactVersion) channel: $(installerChannel) - job: Homebrew displayName: Homebrew Cask timeoutInMinutes: 30 + condition: and(succeeded(), eq(variables['installerChannel'], 'stable')) pool: name: Azure Pipelines vmImage: macOS-latest-internal @@ -401,4 +428,4 @@ extends: - template: /eng/pipelines/templates/prepare-homebrew-cask.yml@self parameters: version: $(aspireVersion) - channel: $(installerChannel) + artifactVersion: $(aspireArtifactVersion) diff --git a/eng/pipelines/release-publish-nuget.yml b/eng/pipelines/release-publish-nuget.yml index 8b8944c4cc7..f75a62e246f 100644 --- a/eng/pipelines/release-publish-nuget.yml +++ b/eng/pipelines/release-publish-nuget.yml @@ -115,14 +115,16 @@ extends: Write-Host "Source Build ID: $(resources.pipeline.aspire-build.runID)" Write-Host "Source Build Name: $(resources.pipeline.aspire-build.runName)" Write-Host "This stage downloads artifacts and re-publishes them so 1ES PT can generate SBOM." + Write-Host "Installer-only mode: ${{ and(eq(parameters.SkipNuGetPublish, true), eq(parameters.SkipChannelPromotion, true)) }}" Write-Host "===============================" displayName: 'Log Stage Info' # Download artifacts from the source build pipeline - - download: aspire-build - displayName: 'Download PackageArtifacts from Source Build' - artifact: PackageArtifacts - patterns: '**/*.nupkg' + - ${{ if not(and(eq(parameters.SkipNuGetPublish, true), eq(parameters.SkipChannelPromotion, true))) }}: + - download: aspire-build + displayName: 'Download PackageArtifacts from Source Build' + artifact: PackageArtifacts + patterns: '**/*.nupkg' - download: aspire-build displayName: 'Download WinGet Manifests from Source Build' @@ -133,27 +135,39 @@ extends: artifact: homebrew-cask-stable # Move artifacts to expected location for output - - powershell: | - $sourcePath = "$(Pipeline.Workspace)/aspire-build/PackageArtifacts" - $targetPath = "$(Pipeline.Workspace)/packages/PackageArtifacts" - - Write-Host "Moving artifacts from $sourcePath to $targetPath" - - if (!(Test-Path $targetPath)) { - New-Item -ItemType Directory -Path $targetPath -Force | Out-Null - } - - # Copy all nupkg files - $packages = Get-ChildItem -Path $sourcePath -Filter "*.nupkg" -Recurse - Write-Host "Found $($packages.Count) packages to copy" - - foreach ($pkg in $packages) { - Copy-Item $pkg.FullName -Destination $targetPath -Force - Write-Host " Copied: $($pkg.Name)" - } - - Write-Host "✓ Artifacts prepared for SBOM generation" - displayName: 'Prepare Artifacts for Publishing' + - ${{ if not(and(eq(parameters.SkipNuGetPublish, true), eq(parameters.SkipChannelPromotion, true))) }}: + - powershell: | + $sourcePath = "$(Pipeline.Workspace)/aspire-build/PackageArtifacts" + $targetPath = "$(Pipeline.Workspace)/packages/PackageArtifacts" + + Write-Host "Moving artifacts from $sourcePath to $targetPath" + + if (!(Test-Path $targetPath)) { + New-Item -ItemType Directory -Path $targetPath -Force | Out-Null + } + + # Copy all nupkg files + $packages = Get-ChildItem -Path $sourcePath -Filter "*.nupkg" -Recurse + Write-Host "Found $($packages.Count) packages to copy" + + foreach ($pkg in $packages) { + Copy-Item $pkg.FullName -Destination $targetPath -Force + Write-Host " Copied: $($pkg.Name)" + } + + Write-Host "✓ Artifacts prepared for SBOM generation" + displayName: 'Prepare Artifacts for Publishing' + + - ${{ if and(eq(parameters.SkipNuGetPublish, true), eq(parameters.SkipChannelPromotion, true)) }}: + - powershell: | + $targetPath = "$(Pipeline.Workspace)/packages/PackageArtifacts" + + if (!(Test-Path $targetPath)) { + New-Item -ItemType Directory -Path $targetPath -Force | Out-Null + } + + Write-Host "Installer-only run detected; created empty PackageArtifacts placeholder." + displayName: 'Prepare Empty PackageArtifacts Placeholder' # Copy installer artifacts to expected locations for output - powershell: | @@ -225,118 +239,121 @@ extends: Write-Host "Dry Run: ${{ parameters.DryRun }}" Write-Host "Skip NuGet Publish: ${{ parameters.SkipNuGetPublish }}" Write-Host "Skip Channel Promotion: ${{ parameters.SkipChannelPromotion }}" + Write-Host "Installer-only mode: ${{ and(eq(parameters.SkipNuGetPublish, true), eq(parameters.SkipChannelPromotion, true)) }}" Write-Host "===================================" displayName: 'Validate Parameters' # ===== EXTRACT BAR BUILD ID ===== - - powershell: | - $buildId = "$(resources.pipeline.aspire-build.runID)" - $org = "$(System.CollectionUri)" - $project = "internal" + - ${{ if eq(parameters.SkipChannelPromotion, false) }}: + - powershell: | + $buildId = "$(resources.pipeline.aspire-build.runID)" + $org = "$(System.CollectionUri)" + $project = "internal" - Write-Host "Fetching build tags for build: $buildId" + Write-Host "Fetching build tags for build: $buildId" - # Use Azure DevOps REST API to get build tags - $uri = "${org}${project}/_apis/build/builds/${buildId}/tags?api-version=7.0" - Write-Host "API URI: $uri" + # Use Azure DevOps REST API to get build tags + $uri = "${org}${project}/_apis/build/builds/${buildId}/tags?api-version=7.0" + Write-Host "API URI: $uri" - try { - $response = Invoke-RestMethod -Uri $uri -Headers @{ - Authorization = "Bearer $(System.AccessToken)" - } -Method Get + try { + $response = Invoke-RestMethod -Uri $uri -Headers @{ + Authorization = "Bearer $(System.AccessToken)" + } -Method Get - Write-Host "Build tags found: $($response.value -join ', ')" + Write-Host "Build tags found: $($response.value -join ', ')" - # Find the BAR ID tag - $barIdTag = $response.value | Where-Object { $_ -match 'BAR ID - (\d+)' } + # Find the BAR ID tag + $barIdTag = $response.value | Where-Object { $_ -match 'BAR ID - (\d+)' } - if ($barIdTag -and $barIdTag -match 'BAR ID - (\d+)') { - $barBuildId = $Matches[1] - Write-Host "✓ Extracted BAR Build ID: $barBuildId" - Write-Host "##vso[task.setvariable variable=BarBuildId]$barBuildId" - } else { - Write-Error "Could not find BAR ID tag in build $buildId. Tags found: $($response.value -join ', ')" + if ($barIdTag -and $barIdTag -match 'BAR ID - (\d+)') { + $barBuildId = $Matches[1] + Write-Host "✓ Extracted BAR Build ID: $barBuildId" + Write-Host "##vso[task.setvariable variable=BarBuildId]$barBuildId" + } else { + Write-Error "Could not find BAR ID tag in build $buildId. Tags found: $($response.value -join ', ')" + exit 1 + } + } catch { + Write-Error "Failed to fetch build tags: $_" exit 1 } - } catch { - Write-Error "Failed to fetch build tags: $_" - exit 1 - } - displayName: 'Extract BAR Build ID' - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) + displayName: 'Extract BAR Build ID' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) # ===== DOWNLOAD PACKAGES ===== # Artifacts are downloaded automatically via templateContext.inputs above - - task: UseDotNet@2 - displayName: 'Install .NET 10 SDK' - inputs: - packageType: 'sdk' - version: '10.0.x' + - ${{ if eq(parameters.SkipNuGetPublish, false) }}: + - task: UseDotNet@2 + displayName: 'Install .NET 10 SDK' + inputs: + packageType: 'sdk' + version: '10.0.x' - - powershell: | - $packagesPath = "$(Pipeline.Workspace)/packages/PackageArtifacts" - Write-Host "=== Package Inventory ===" + - powershell: | + $packagesPath = "$(Pipeline.Workspace)/packages/PackageArtifacts" + Write-Host "=== Package Inventory ===" - $packages = Get-ChildItem -Path $packagesPath -Filter "*.nupkg" -Recurse - Write-Host "Found $($packages.Count) packages:" + $packages = Get-ChildItem -Path $packagesPath -Filter "*.nupkg" -Recurse + Write-Host "Found $($packages.Count) packages:" - foreach ($pkg in $packages) { - $sizeMB = [math]::Round($pkg.Length / 1MB, 2) - Write-Host " - $($pkg.Name) ($sizeMB MB)" - } + foreach ($pkg in $packages) { + $sizeMB = [math]::Round($pkg.Length / 1MB, 2) + Write-Host " - $($pkg.Name) ($sizeMB MB)" + } - if ($packages.Count -eq 0) { - Write-Error "No packages found in artifacts!" - exit 1 - } + if ($packages.Count -eq 0) { + Write-Error "No packages found in artifacts!" + exit 1 + } - Write-Host "===========================" - displayName: 'List Packages' + Write-Host "===========================" + displayName: 'List Packages' - # ===== VERIFY SIGNATURES ===== - - powershell: | - $packagesPath = "$(Pipeline.Workspace)/packages/PackageArtifacts" - Write-Host "=== Verifying Package Signatures ===" - - $packages = Get-ChildItem -Path $packagesPath -Filter "*.nupkg" -Recurse - $failedVerification = @() - - foreach ($package in $packages) { - Write-Host "Verifying: $($package.Name)" - - # Use $ErrorActionPreference to prevent PowerShell from treating stderr as terminating error - $originalErrorActionPreference = $ErrorActionPreference - $ErrorActionPreference = 'Continue' - $result = dotnet nuget verify $package.FullName 2>&1 - $verifyExitCode = $LASTEXITCODE - $ErrorActionPreference = $originalErrorActionPreference - - if ($verifyExitCode -ne 0) { - Write-Host " ❌ Signature verification FAILED" - Write-Host $result - $failedVerification += $package.Name - } else { - Write-Host " ✓ Signature valid" + # ===== VERIFY SIGNATURES ===== + - powershell: | + $packagesPath = "$(Pipeline.Workspace)/packages/PackageArtifacts" + Write-Host "=== Verifying Package Signatures ===" + + $packages = Get-ChildItem -Path $packagesPath -Filter "*.nupkg" -Recurse + $failedVerification = @() + + foreach ($package in $packages) { + Write-Host "Verifying: $($package.Name)" + + # Use $ErrorActionPreference to prevent PowerShell from treating stderr as terminating error + $originalErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = 'Continue' + $result = dotnet nuget verify $package.FullName 2>&1 + $verifyExitCode = $LASTEXITCODE + $ErrorActionPreference = $originalErrorActionPreference + + if ($verifyExitCode -ne 0) { + Write-Host " ❌ Signature verification FAILED" + Write-Host $result + $failedVerification += $package.Name + } else { + Write-Host " ✓ Signature valid" + } } - } - if ($failedVerification.Count -gt 0) { - Write-Host "" - Write-Host "=== SIGNATURE VERIFICATION FAILED ===" - Write-Host "The following packages failed signature verification:" - foreach ($pkg in $failedVerification) { - Write-Host " - $pkg" + if ($failedVerification.Count -gt 0) { + Write-Host "" + Write-Host "=== SIGNATURE VERIFICATION FAILED ===" + Write-Host "The following packages failed signature verification:" + foreach ($pkg in $failedVerification) { + Write-Host " - $pkg" + } + Write-Error "Package signature verification failed. Aborting release." + exit 1 } - Write-Error "Package signature verification failed. Aborting release." - exit 1 - } - Write-Host "" - Write-Host "✓ All $($packages.Count) packages passed signature verification" - Write-Host "===========================" - displayName: 'Verify Package Signatures' + Write-Host "" + Write-Host "✓ All $($packages.Count) packages passed signature verification" + Write-Host "===========================" + displayName: 'Verify Package Signatures' # ===== PUBLISH TO NUGET ===== # Dry Run: List packages that would be published (skip actual publish) @@ -450,7 +467,11 @@ extends: Write-Host "╠═══════════════════════════════════════════════════════════════╣" Write-Host "║ Source Build: $(resources.pipeline.aspire-build.runName)" Write-Host "║ Source Build ID: $(resources.pipeline.aspire-build.runID)" - Write-Host "║ BAR Build ID: $(BarBuildId)" + if ("${{ parameters.SkipChannelPromotion }}" -eq "true") { + Write-Host "║ BAR Build ID: (SKIPPED)" + } else { + Write-Host "║ BAR Build ID: $(BarBuildId)" + } Write-Host "║ GA Channel: ${{ parameters.GaChannelName }}" Write-Host "║ Dry Run: ${{ parameters.DryRun }}" Write-Host "╠═══════════════════════════════════════════════════════════════╣" @@ -526,5 +547,4 @@ extends: - template: /eng/pipelines/templates/publish-homebrew.yml@self parameters: caskArtifactPath: $(Pipeline.Workspace)/homebrew/homebrew-cask-stable - channel: stable dryRun: ${{ parameters.DryRun }} diff --git a/eng/pipelines/templates/prepare-homebrew-cask.yml b/eng/pipelines/templates/prepare-homebrew-cask.yml index 7d17038fd01..8273527099a 100644 --- a/eng/pipelines/templates/prepare-homebrew-cask.yml +++ b/eng/pipelines/templates/prepare-homebrew-cask.yml @@ -2,116 +2,153 @@ parameters: - name: version type: string default: '' - - name: channel + - name: artifactVersion type: string + default: '' + - name: archiveRoot + type: string + default: '' + - name: validateUrls + type: boolean + default: true + - name: runInstallTest + type: boolean + default: true steps: - bash: | set -euo pipefail version='${{ parameters.version }}' - channel='${{ parameters.channel }}' + artifactVersion='${{ parameters.artifactVersion }}' if [ -z "$version" ]; then echo "##[error]Version parameter is required" exit 1 fi - if [ -z "$channel" ]; then - echo "##[error]Channel parameter is required (stable or prerelease)" - exit 1 - fi - - if [ "$channel" != "stable" ] && [ "$channel" != "prerelease" ]; then - echo "##[error]Channel must be 'stable' or 'prerelease', got: $channel" - exit 1 - fi - echo "Version: $version" - echo "Channel: $channel" + echo "Artifact version: ${artifactVersion:-$version}" echo "##vso[task.setvariable variable=CliVersion]$version" - echo "##vso[task.setvariable variable=CliChannel]$channel" + echo "##vso[task.setvariable variable=CliArtifactVersion]${artifactVersion:-$version}" displayName: 🟣Set version ${{ parameters.version }} - bash: | set -euo pipefail version="$(CliVersion)" - channel="$(CliChannel)" + artifactVersion="$(CliArtifactVersion)" outputDir="$(Build.StagingDirectory)/homebrew-cask" mkdir -p "$outputDir" + outputFile="$outputDir/aspire.rb" - if [ "$channel" = "prerelease" ]; then - outputFile="$outputDir/aspire@prerelease.rb" - else - outputFile="$outputDir/aspire.rb" + echo "Generating Homebrew cask for Aspire version $version" + + args=( + --version "$version" + --artifact-version "$artifactVersion" + --output "$outputFile" + ) + + if [ -n "${ARCHIVE_ROOT:-}" ]; then + args+=(--archive-root "$ARCHIVE_ROOT") fi - echo "Generating Homebrew cask for Aspire version $version (channel: $channel)" + validateUrlsNormalized="$(printf '%s' "${VALIDATE_URLS:-false}" | tr '[:upper:]' '[:lower:]')" + if [ "$validateUrlsNormalized" = "true" ]; then + args+=(--validate-urls) + fi - "$(Build.SourcesDirectory)/eng/homebrew/generate-cask.sh" \ - --version "$version" \ - --channel "$channel" \ - --output "$outputFile" \ - --validate-urls + "$(Build.SourcesDirectory)/eng/homebrew/generate-cask.sh" "${args[@]}" echo "" echo "Generated cask:" cat "$outputFile" displayName: 🟣Generate Homebrew cask + env: + ARCHIVE_ROOT: '${{ parameters.archiveRoot }}' + VALIDATE_URLS: '${{ parameters.validateUrls }}' - bash: | set -euo pipefail - channel="$(CliChannel)" + caskFile="aspire.rb" + caskName="aspire" + caskPath="$(Build.StagingDirectory)/homebrew-cask/$caskFile" + firstLetter="${caskName:0:1}" + targetPath="Casks/$firstLetter/$caskFile" + tapName="local/aspire" + tapRoot="$(brew --repository)/Library/Taps/local/homebrew-aspire" - if [ "$channel" = "prerelease" ]; then - caskFile="aspire@prerelease.rb" - caskName="aspire@prerelease" - else - caskFile="aspire.rb" - caskName="aspire" - fi + cleanup() { + brew untap "$tapName" >/dev/null 2>&1 || true + } - caskPath="$(Build.StagingDirectory)/homebrew-cask/$caskFile" + trap cleanup EXIT echo "Validating Ruby syntax..." ruby -c "$caskPath" echo "Ruby syntax OK" + brew tap-new --no-git "$tapName" + mkdir -p "$tapRoot/Casks" + cp "$caskPath" "$tapRoot/Casks/$caskFile" + tappedCaskPath="$tapRoot/Casks/$caskFile" + + echo "" + echo "Applying Homebrew style fixes in local tap..." + brew style --fix "$tappedCaskPath" + cp "$tappedCaskPath" "$caskPath" + echo "Homebrew style OK" + echo "" echo "Auditing cask via local tap..." - brew tap-new --no-git local/aspire - mkdir -p "$(brew --repository)/Library/Taps/local/homebrew-aspire/Casks" - cp "$caskPath" "$(brew --repository)/Library/Taps/local/homebrew-aspire/Casks/$caskFile" - auditCode=0 - brew audit --cask "local/aspire/$caskName" || auditCode=$? + upstreamStatusCode="$(curl -sS -o /dev/null -w "%{http_code}" "https://api.github.com/repos/Homebrew/homebrew-cask/contents/$targetPath")" + auditArgs=(--cask --online "$tapName/$caskName") + auditCommand="brew audit --cask --online $tapName/$caskName" + isNewCask=false + if [ "$upstreamStatusCode" = "404" ]; then + echo "Detected new upstream cask; running new-cask audit." + auditArgs=(--cask --new --online "$tapName/$caskName") + auditCommand="brew audit --cask --new --online $tapName/$caskName" + isNewCask=true + elif [ "$upstreamStatusCode" = "200" ]; then + echo "Detected existing upstream cask; running standard online audit." + else + echo "##[error]Could not determine whether $targetPath exists upstream (HTTP $upstreamStatusCode)" + exit 1 + fi - brew untap local/aspire + auditCode=0 + brew audit "${auditArgs[@]}" || auditCode=$? if [ $auditCode -ne 0 ]; then echo "##[error]brew audit failed" exit $auditCode fi + echo "##vso[task.setvariable variable=HomebrewAuditCommand]$auditCommand" + echo "##vso[task.setvariable variable=HomebrewIsNewCask]$isNewCask" echo "brew audit passed" + trap - EXIT + cleanup displayName: 🟣Validate cask syntax and audit - bash: | set -euo pipefail - channel="$(CliChannel)" - - if [ "$channel" = "prerelease" ]; then - caskFile="aspire@prerelease.rb" - caskName="aspire@prerelease" - else - caskFile="aspire.rb" - caskName="aspire" - fi - + caskFile="aspire.rb" + caskName="aspire" caskPath="$(Build.StagingDirectory)/homebrew-cask/$caskFile" + tapName="local/aspire-test" + tapRoot="$(brew --repository)/Library/Taps/local/homebrew-aspire-test" echo "Testing cask install/uninstall: $caskPath" echo "" + cleanup() { + brew untap "$tapName" >/dev/null 2>&1 || true + } + + trap cleanup EXIT + # Verify aspire is NOT already installed echo "Verifying aspire is not already installed..." if command -v aspire &>/dev/null; then @@ -123,15 +160,14 @@ steps: # Set up a local tap so brew accepts the cask echo "" echo "Setting up local tap..." - brew tap-new --no-git local/aspire-test - tapCaskDir="$(brew --repository)/Library/Taps/local/homebrew-aspire-test/Casks" - mkdir -p "$tapCaskDir" - cp "$caskPath" "$tapCaskDir/$caskFile" + brew tap-new --no-git "$tapName" + mkdir -p "$tapRoot/Casks" + cp "$caskPath" "$tapRoot/Casks/$caskFile" # Install from local tap echo "" echo "Installing aspire from local tap..." - brew install --cask "local/aspire-test/$caskName" + HOMEBREW_NO_INSTALL_FROM_API=1 brew install --cask "$tapName/$caskName" echo "✅ Install succeeded" # Verify aspire is now available and runs @@ -140,32 +176,73 @@ steps: if ! command -v aspire &>/dev/null; then echo "##[error]aspire command not found in PATH after install" # Show brew info for diagnostics - brew info --cask "local/aspire-test/$caskName" || true - brew untap local/aspire-test + brew info --cask "$tapName/$caskName" || true exit 1 fi echo " Path: $(command -v aspire)" - aspireVersion="$(aspire --version 2>&1)" || true + aspireVersion="$(aspire --version 2>&1)" echo " Version: $aspireVersion" echo "✅ aspire CLI verified" # Uninstall echo "" echo "Uninstalling aspire..." - brew uninstall --cask "local/aspire-test/$caskName" + brew uninstall --cask "$tapName/$caskName" echo "✅ Uninstall succeeded" # Clean up tap - brew untap local/aspire-test + trap - EXIT + cleanup # Verify aspire is removed if command -v aspire &>/dev/null; then - echo "##[warning]aspire command still found in PATH after uninstall" + echo "##[error]aspire command still found in PATH after uninstall" + exit 1 else echo " Confirmed: aspire is no longer in PATH" fi displayName: 🟣Test cask install/uninstall + condition: and(succeeded(), eq('${{ parameters.runInstallTest }}', 'true')) + + - bash: | + set -euo pipefail + outputPath="$(Build.StagingDirectory)/homebrew-cask/validation-summary.json" + cat > "$outputPath" <$null - if ($LASTEXITCODE -ne 0) { - git clone "https://github.com/${botUser}/homebrew-cask.git" $repoDir + Write-Host "Waiting for fork creation ($attempt/12)..." + } + + if (-not $forkReady) { + Write-Error "Timed out waiting for fork $botUser/homebrew-cask to become available." + exit 1 + } + } else { + Write-Host "Fork already exists: $botUser/homebrew-cask" + } + + $branchName = "$($caskName -replace '@', '-')-$version" + $firstLetter = $caskName.Substring(0, 1) + $targetPath = "Casks/$firstLetter/$caskFile" + $targetPathForUri = "Casks/$firstLetter/$([Uri]::EscapeDataString($caskFile))" + $upstreamBranch = Invoke-GitHubApi -Method Get -Uri "https://api.github.com/repos/Homebrew/homebrew-cask/branches/$defaultBranchForUri" -Body $null + $upstreamSha = $upstreamBranch.commit.sha + $caskContent = (Get-Content -Path $caskPath -Raw) -replace "`r`n", "`n" + if (-not $caskContent.EndsWith("`n")) { + $caskContent += "`n" } - Push-Location $repoDir + $upstreamContent = $null try { - git remote add upstream https://github.com/Homebrew/homebrew-cask.git 2>$null - git fetch upstream master - git checkout -B "aspire-${version}" upstream/master - - # Casks are organized by first letter: Casks/a/aspire.rb - $firstLetter = $caskName.Substring(0, 1) - $targetDir = "Casks/$firstLetter" - New-Item -ItemType Directory -Path $targetDir -Force | Out-Null - Copy-Item $caskPath "$targetDir/$caskFile" - - git config user.name "dotnet-bot" - git config user.email "dotnet-bot@microsoft.com" - git add "$targetDir/$caskFile" - git commit -m "$caskName $version" - git push --force origin "aspire-${version}" - - # Create PR (or update existing) - $existingPR = gh pr list --repo Homebrew/homebrew-cask --head "${botUser}:aspire-${version}" --json number --jq '.[0].number' 2>$null - if ($existingPR) { - Write-Host "PR #$existingPR already exists — updated branch" - } else { - gh pr create ` - --repo Homebrew/homebrew-cask ` - --title "$caskName $version" ` - --body "Update $caskName to version $version." ` - --head "${botUser}:aspire-${version}" - Write-Host "PR created successfully" - } - } finally { - Pop-Location + $upstreamFile = Invoke-GitHubApi -Method Get -Uri "https://api.github.com/repos/Homebrew/homebrew-cask/contents/${targetPathForUri}?ref=$defaultBranchForUri" -Body $null + if ($upstreamFile.content) { + $upstreamContent = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String(($upstreamFile.content -replace '\s', ''))) -replace "`r`n", "`n" + } + } + catch { + $statusCode = Get-StatusCode -ErrorRecord $_ + if ($statusCode -ne 404) { + throw + } + } + + if ($upstreamContent -eq $caskContent) { + Write-Host "No Homebrew changes to submit; upstream already matches $caskName $version." + exit 0 + } + + $branchRefUri = "https://api.github.com/repos/$botUser/homebrew-cask/git/refs/heads/$branchName" + try { + Invoke-GitHubApi -Method Get -Uri $branchRefUri -Body $null | Out-Null + Invoke-GitHubApi -Method Patch -Uri $branchRefUri -Body @{ + sha = $upstreamSha + force = $true + } | Out-Null + Write-Host "Reset branch $branchName to upstream/$defaultBranch" + } + catch { + $statusCode = Get-StatusCode -ErrorRecord $_ + if ($statusCode -eq 404) { + Invoke-GitHubApi -Method Post -Uri "https://api.github.com/repos/$botUser/homebrew-cask/git/refs" -Body @{ + ref = "refs/heads/$branchName" + sha = $upstreamSha + } | Out-Null + Write-Host "Created branch $branchName from upstream/$defaultBranch" + } + else { + throw + } + } + + $branchFileUri = "https://api.github.com/repos/$botUser/homebrew-cask/contents/${targetPathForUri}?ref=$([Uri]::EscapeDataString($branchName))" + $existingBranchFileSha = $null + try { + $branchFile = Invoke-GitHubApi -Method Get -Uri $branchFileUri -Body $null + $existingBranchFileSha = $branchFile.sha + } + catch { + $statusCode = Get-StatusCode -ErrorRecord $_ + if ($statusCode -ne 404) { + throw + } + } + + $putBody = @{ + message = "$caskName $version" + content = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($caskContent)) + branch = $branchName + } + + if ($existingBranchFileSha) { + $putBody.sha = $existingBranchFileSha + } + + $contentResult = Invoke-GitHubApi -Method Put -Uri "https://api.github.com/repos/$botUser/homebrew-cask/contents/$targetPathForUri" -Body $putBody + Write-Host "Updated $targetPath on branch $branchName with commit $($contentResult.commit.sha)" + + $compareUri = "https://api.github.com/repos/Homebrew/homebrew-cask/compare/$defaultBranchForUri...$([Uri]::EscapeDataString("${botUser}:$branchName"))" + $compareResult = $null + for ($attempt = 1; $attempt -le 10; $attempt++) { + try { + $compareResult = Invoke-GitHubApi -Method Get -Uri $compareUri -Body $null + if ($compareResult.ahead_by -gt 0) { + break + } + + Write-Host "Waiting for branch comparison to reflect new commit ($attempt/10)..." + } + catch { + $statusCode = Get-StatusCode -ErrorRecord $_ + Write-Host "Branch comparison is not ready yet ($statusCode) ($attempt/10)" + } + + Start-Sleep -Seconds 3 + } + + if ($null -eq $compareResult -or $compareResult.ahead_by -le 0) { + Write-Error "Branch $branchName does not contain commits ahead of Homebrew/homebrew-cask:$defaultBranch, so a PR cannot be created." + exit 1 + } + + Write-Host "Branch comparison status: $($compareResult.status); ahead_by=$($compareResult.ahead_by)" + + # Create PR (or update existing) + $encodedHead = [Uri]::EscapeDataString("${botUser}:$branchName") + $existingPRsResponse = Invoke-GitHubApi -Method Get -Uri "https://api.github.com/repos/Homebrew/homebrew-cask/pulls?head=$encodedHead&state=all" -Body $null + $existingPRs = @( + foreach ($existingPr in $existingPRsResponse) { + if ($null -ne $existingPr) { + $existingPr + } + } + ) + $existingOpenPr = $existingPRs | Where-Object { $_.state -eq 'open' } | Select-Object -First 1 + $existingClosedPrs = @($existingPRs | Where-Object { $_.state -ne 'open' } | Sort-Object updated_at -Descending) + $supersededPullRequestNumbers = @( + foreach ($closedPr in $existingClosedPrs) { + [Convert]::ToInt32("$($closedPr.number)", [System.Globalization.CultureInfo]::InvariantCulture) + } + ) + $isStableCask = [bool]$validationSummary.isStableRelease + $pullRequestBody = Get-HomebrewPullRequestBody -Version $version -CaskName $caskName -CaskFile $caskFile -IsStable $isStableCask -ValidationSummary $validationSummary -SupersededPullRequestNumbers $supersededPullRequestNumbers + + if ($existingOpenPr) { + $updatedPr = Invoke-GitHubApi -Method Patch -Uri "https://api.github.com/repos/Homebrew/homebrew-cask/pulls/$($existingOpenPr.number)" -Body @{ + title = "$caskName $version" + body = $pullRequestBody + } + + Write-Host "PR #$($existingOpenPr.number) already exists — updated title/body at $($updatedPr.html_url)" + + if (-not [bool]$existingOpenPr.draft) { + Write-Host "Converting existing PR #$($existingOpenPr.number) to draft..." + + $graphQlData = Invoke-GitHubGraphQL -Query @' + mutation ConvertPullRequestToDraft($pullRequestId: ID!) { + convertPullRequestToDraft(input: { pullRequestId: $pullRequestId }) { + pullRequest { + number + isDraft + url + } + } + } + '@ -Variables @{ + pullRequestId = $existingOpenPr.node_id + } + + if (-not $graphQlData.convertPullRequestToDraft.pullRequest.isDraft) { + throw "Failed to convert PR #$($existingOpenPr.number) to draft." + } + + Write-Host "PR #$($existingOpenPr.number) is now draft." + } + } else { + if ($existingClosedPrs.Count -gt 0) { + $closedPrSummary = ($existingClosedPrs | ForEach-Object { "#$($_.number)" }) -join ', ' + Write-Host "Found prior closed PRs for ${botUser}:${branchName}: $closedPrSummary" + } + + $createdPr = Invoke-GitHubApi -Method Post -Uri 'https://api.github.com/repos/Homebrew/homebrew-cask/pulls' -Body @{ + title = "$caskName $version" + body = $pullRequestBody + head = "${botUser}:$branchName" + base = $defaultBranch + draft = $true + } + + Write-Host "Draft PR created successfully: #$($createdPr.number) $($createdPr.html_url)" } displayName: '🟣Submit PR to Homebrew/homebrew-cask' condition: and(succeeded(), eq('${{ parameters.dryRun }}', 'false')) diff --git a/eng/pipelines/templates/publish-winget.yml b/eng/pipelines/templates/publish-winget.yml index 74dc0cf78b4..780e6cbac38 100644 --- a/eng/pipelines/templates/publish-winget.yml +++ b/eng/pipelines/templates/publish-winget.yml @@ -21,6 +21,7 @@ steps: - powershell: | $ErrorActionPreference = 'Stop' $manifestRoot = '${{ parameters.manifestArtifactPath }}' + $packageId = '${{ parameters.packageIdentifier }}' Write-Host "=== WinGet Manifests ===" Get-ChildItem -Path $manifestRoot -Recurse | Format-Table FullName @@ -35,14 +36,36 @@ steps: exit 1 } - Write-Host "Manifest directory: $manifestDir" - Write-Host "##vso[task.setvariable variable=WinGetManifestDir]$manifestDir" + $submissionDir = Join-Path '$(Build.StagingDirectory)' 'winget-submit-manifests' + if (Test-Path $submissionDir) { + Remove-Item -Path $submissionDir -Recurse -Force + } + + New-Item -ItemType Directory -Path $submissionDir -Force | Out-Null + Get-ChildItem -Path $manifestDir -File -Filter "*.yaml" | ForEach-Object { + Copy-Item -Path $_.FullName -Destination (Join-Path $submissionDir $_.Name) -Force + } - # Extract version from manifest directory name (e.g., .../Microsoft.Aspire/13.2.0/) + Write-Host "Manifest directory: $submissionDir" + Write-Host "##vso[task.setvariable variable=WinGetManifestDir]$submissionDir" + + $versionManifestPath = Join-Path $submissionDir "$packageId.yaml" + + # Extract version from the version manifest when no explicit version is provided. $version = '${{ parameters.version }}' if ([string]::IsNullOrWhiteSpace($version)) { - $version = Split-Path $manifestDir -Leaf - Write-Host "Extracted version from directory: $version" + if (Test-Path $versionManifestPath) { + $versionMatch = Select-String -Path $versionManifestPath -Pattern '^\s*PackageVersion:\s*(.+)\s*$' | Select-Object -First 1 + if ($versionMatch) { + $version = $versionMatch.Matches[0].Groups[1].Value.Trim() + Write-Host "Extracted version from version manifest: $version" + } + } + + if ([string]::IsNullOrWhiteSpace($version)) { + $version = Split-Path $manifestDir -Leaf + Write-Host "Fell back to directory name for version: $version" + } } else { Write-Host "Using provided version: $version" } @@ -160,8 +183,30 @@ steps: Write-Host "Submitting WinGet manifests for $packageId version $version" Write-Host "Manifest directory: $manifestDir" Write-Host "Manifest files:" - Get-ChildItem -Path $manifestDir -Filter "*.yaml" | ForEach-Object { Write-Host " - $($_.Name)" } + Get-ChildItem -Path $manifestDir -File -Filter "*.yaml" | Sort-Object Name | ForEach-Object { Write-Host " - $($_.Name)" } + + $versionManifest = Join-Path $manifestDir "$packageId.yaml" + $installerManifest = Join-Path $manifestDir "$packageId.installer.yaml" + $localeManifests = Get-ChildItem -Path $manifestDir -File -Filter "$packageId.locale.*.yaml" | Sort-Object Name + + $missingManifests = @() + foreach ($requiredManifest in @($versionManifest, $installerManifest)) { + if (-not (Test-Path $requiredManifest)) { + $missingManifests += $requiredManifest + } + } + + if ($localeManifests.Count -eq 0) { + Write-Error "No locale manifests were found for $packageId in $manifestDir" + exit 1 + } + + if ($missingManifests.Count -gt 0) { + Write-Error "Missing required manifest files: $($missingManifests -join ', ')" + exit 1 + } + Write-Host "Submitting clean manifest directory to wingetcreate: $manifestDir" $output = & "$(Build.StagingDirectory)/wingetcreate.exe" submit $manifestDir ` --token $token ` --prtitle "Update $packageId to version $version" 2>&1 diff --git a/eng/testing/github-ci-trigger-patterns.txt b/eng/testing/github-ci-trigger-patterns.txt index 0287dc81ab7..28df2daa936 100644 --- a/eng/testing/github-ci-trigger-patterns.txt +++ b/eng/testing/github-ci-trigger-patterns.txt @@ -26,6 +26,8 @@ eng/testing/github-ci-trigger-patterns.txt # Engineering pipeline scripts (Azure DevOps, not used in the GitHub CI build) eng/pipelines/** +eng/homebrew/** +eng/winget/** eng/test-configuration.json Aspire-Core.slnf diff --git a/eng/winget/README.md b/eng/winget/README.md index af32e1ad807..d42547f9af3 100644 --- a/eng/winget/README.md +++ b/eng/winget/README.md @@ -41,7 +41,7 @@ Windows only (x64, arm64). Installers are zip archives containing a portable `as ## Artifact URLs ```text -https://ci.dot.net/public/aspire/{VERSION}/aspire-cli-win-{arch}-{VERSION}.zip +https://ci.dot.net/public/aspire/{ARTIFACT_VERSION}/aspire-cli-win-{arch}-{VERSION}.zip ``` Where arch is `x64` or `arm64`. diff --git a/eng/winget/generate-manifests.ps1 b/eng/winget/generate-manifests.ps1 index d583809138b..c97ea2d5ae9 100644 --- a/eng/winget/generate-manifests.ps1 +++ b/eng/winget/generate-manifests.ps1 @@ -5,10 +5,13 @@ .DESCRIPTION This script generates the required WinGet manifest files (version, locale, and installer) from templates by substituting version numbers, URLs, and computing SHA256 hashes. - Installer URLs are derived from the version and RIDs using the ci.dot.net URL pattern. + Installer URLs are derived from the installer version, artifact version, and RIDs using the ci.dot.net URL pattern. .PARAMETER Version - The version number for the package (e.g., "13.3.0-preview.1.26111.5"). + The package version and installer filename version (e.g., "13.2.0"). + +.PARAMETER ArtifactVersion + The version segment used in the ci.dot.net artifact path. Defaults to Version. .PARAMETER TemplateDir The directory containing the manifest templates to use. @@ -24,6 +27,10 @@ e.g., "./manifests/m/Microsoft/Aspire/{Version}" for Microsoft.Aspire or "./manifests/m/Microsoft/Aspire/Prerelease/{Version}" for Microsoft.Aspire.Prerelease. +.PARAMETER ArchiveRoot + Root directory containing locally built CLI archives. When specified, SHA256 hashes + are computed from matching local files instead of downloading from installer URLs. + .PARAMETER ReleaseNotesUrl URL to the release notes page. If not specified, derived from the version (e.g., "13.2.0" -> "https://aspire.dev/whats-new/aspire-13-2/"). @@ -38,6 +45,7 @@ .EXAMPLE ./generate-manifests.ps1 -Version "13.2.0" ` + -ArtifactVersion "13.2.0-preview.1.26111.5" ` -TemplateDir "./eng/winget/microsoft.aspire" ` -Rids "win-x64,win-arm64" -ValidateUrls #> @@ -47,6 +55,9 @@ param( [Parameter(Mandatory = $true)] [string]$Version, + [Parameter(Mandatory = $false)] + [string]$ArtifactVersion, + [Parameter(Mandatory = $true)] [string]$TemplateDir, @@ -56,6 +67,9 @@ param( [Parameter(Mandatory = $false)] [string]$OutputPath, + [Parameter(Mandatory = $false)] + [string]$ArchiveRoot, + [Parameter(Mandatory = $false)] [string]$ReleaseNotesUrl, @@ -65,6 +79,10 @@ param( $ErrorActionPreference = 'Stop' +if ([string]::IsNullOrWhiteSpace($ArtifactVersion)) { + $ArtifactVersion = $Version +} + # Determine script paths $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -74,6 +92,11 @@ if (-not (Test-Path $TemplateDir)) { exit 1 } +if ($ArchiveRoot -and -not (Test-Path $ArchiveRoot)) { + Write-Error "Archive root directory not found: $ArchiveRoot" + exit 1 +} + # Extract PackageIdentifier from the version template $versionTemplatePath = Join-Path $TemplateDir "Aspire.yaml.template" if (-not (Test-Path $versionTemplatePath)) { @@ -133,14 +156,15 @@ function Get-ArchitectureFromRid { } # Build installer URL from version and RID -# Pattern: https://ci.dot.net/public/aspire/{version}/aspire-cli-{rid}-{version}.zip +# Pattern: https://ci.dot.net/public/aspire/{artifactVersion}/aspire-cli-{rid}-{version}.zip function Get-InstallerUrl { param( [string]$Version, + [string]$ArtifactVersion, [string]$Rid ) - return "https://ci.dot.net/public/aspire/$Version/aspire-cli-$Rid-$Version.zip" + return "https://ci.dot.net/public/aspire/$ArtifactVersion/aspire-cli-$Rid-$Version.zip" } # Function to compute SHA256 hash of a file downloaded from URL @@ -169,6 +193,43 @@ function Get-RemoteFileSha256 { } } +function Get-LocalArchivePath { + param( + [string]$ArchiveRoot, + [string]$Rid, + [string]$Version + ) + + $archiveName = "aspire-cli-$Rid-$Version.zip" + $matches = @(Get-ChildItem -Path $ArchiveRoot -File -Recurse -Filter $archiveName | Sort-Object FullName) + if ($matches.Count -eq 0) { + Write-Error "Could not find local archive '$archiveName' under '$ArchiveRoot'" + exit 1 + } + + if ($matches.Count -gt 1) { + $matchList = $matches | ForEach-Object { " $($_.FullName)" } + Write-Error "Found multiple local archives named '$archiveName' under '$ArchiveRoot':`n$($matchList -join "`n")" + exit 1 + } + + return $matches[0].FullName +} + +function Get-LocalFileSha256 { + param( + [string]$Path, + [string]$Description + ) + + Write-Host "Computing SHA256 for $Description from local file..." + Write-Host " Path: $Path" + + $hash = (Get-FileHash -Path $Path -Algorithm SHA256).Hash.ToUpperInvariant() + Write-Host " SHA256: $hash" + return $hash +} + # Function to process a template file function Process-Template { param( @@ -199,7 +260,7 @@ Write-Host "" $installerEntries = @() foreach ($rid in $ridList) { $arch = Get-ArchitectureFromRid -Rid $rid - $url = Get-InstallerUrl -Version $Version -Rid $rid + $url = Get-InstallerUrl -Version $Version -ArtifactVersion $ArtifactVersion -Rid $rid $installerEntries += @{ Rid = $rid; Architecture = $arch; Url = $url } } @@ -230,7 +291,13 @@ Write-Host "Computing SHA256 hashes..." $installersYaml = "Installers:" foreach ($entry in $installerEntries) { - $sha256 = Get-RemoteFileSha256 -Url $entry.Url -Description "$($entry.Rid) installer" + if ($ArchiveRoot) { + $archivePath = Get-LocalArchivePath -ArchiveRoot $ArchiveRoot -Rid $entry.Rid -Version $Version + $sha256 = Get-LocalFileSha256 -Path $archivePath -Description "$($entry.Rid) installer" + } + else { + $sha256 = Get-RemoteFileSha256 -Url $entry.Url -Description "$($entry.Rid) installer" + } $installersYaml += "`n- Architecture: $($entry.Architecture)" $installersYaml += "`n InstallerUrl: $($entry.Url)" @@ -288,6 +355,6 @@ Write-Host "Successfully generated WinGet manifests at: $OutputPath" Write-Host "" Write-Host "Next steps:" Write-Host " 1. Validate manifests: winget validate --manifest `"$OutputPath`"" -Write-Host " 2. Submit to winget-pkgs: wingetcreate submit --token YOUR_PAT `"$OutputPath`"" +Write-Host " 2. Submit to winget-pkgs: wingetcreate submit --token YOUR_PAT `"$([System.IO.Path]::Combine($OutputPath, "$PackageIdentifier.yaml"))`" `"$([System.IO.Path]::Combine($OutputPath, "$PackageIdentifier.installer.yaml"))`" `"$([System.IO.Path]::Combine($OutputPath, "$PackageIdentifier.locale.en-US.yaml"))`"" exit 0 From 9e2ac828d2172986e15da98f2b171b9495d115e3 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 19 Mar 2026 09:35:32 +0800 Subject: [PATCH 08/49] Improve CLI error messages for dependency and project creation failures (#15350) * Improve CLI error messages for dependency and project creation failures * Use Assert.Collection and Assert.Equal in NewCommandTests * Fix DisplayLines markup test assertion --- src/Aspire.Cli/Commands/InitCommand.cs | 12 ++ src/Aspire.Cli/Commands/NewCommand.cs | 8 ++ .../Interaction/ConsoleInteractionService.cs | 15 ++- src/Aspire.Cli/Resources/ErrorStrings.resx | 2 +- .../InteractionServiceStrings.Designer.cs | 9 ++ .../Resources/InteractionServiceStrings.resx | 3 + .../Resources/xlf/ErrorStrings.cs.xlf | 4 +- .../Resources/xlf/ErrorStrings.de.xlf | 4 +- .../Resources/xlf/ErrorStrings.es.xlf | 4 +- .../Resources/xlf/ErrorStrings.fr.xlf | 4 +- .../Resources/xlf/ErrorStrings.it.xlf | 4 +- .../Resources/xlf/ErrorStrings.ja.xlf | 4 +- .../Resources/xlf/ErrorStrings.ko.xlf | 4 +- .../Resources/xlf/ErrorStrings.pl.xlf | 4 +- .../Resources/xlf/ErrorStrings.pt-BR.xlf | 4 +- .../Resources/xlf/ErrorStrings.ru.xlf | 4 +- .../Resources/xlf/ErrorStrings.tr.xlf | 4 +- .../Resources/xlf/ErrorStrings.zh-Hans.xlf | 4 +- .../Resources/xlf/ErrorStrings.zh-Hant.xlf | 4 +- .../xlf/InteractionServiceStrings.cs.xlf | 5 + .../xlf/InteractionServiceStrings.de.xlf | 5 + .../xlf/InteractionServiceStrings.es.xlf | 5 + .../xlf/InteractionServiceStrings.fr.xlf | 5 + .../xlf/InteractionServiceStrings.it.xlf | 5 + .../xlf/InteractionServiceStrings.ja.xlf | 5 + .../xlf/InteractionServiceStrings.ko.xlf | 5 + .../xlf/InteractionServiceStrings.pl.xlf | 5 + .../xlf/InteractionServiceStrings.pt-BR.xlf | 5 + .../xlf/InteractionServiceStrings.ru.xlf | 5 + .../xlf/InteractionServiceStrings.tr.xlf | 5 + .../xlf/InteractionServiceStrings.zh-Hans.xlf | 5 + .../xlf/InteractionServiceStrings.zh-Hant.xlf | 5 + .../Commands/InitCommandTests.cs | 107 +++++++++++++++ .../Commands/NewCommandTests.cs | 124 +++++++++++++++++- .../DotNetSdkInstallerTests.cs | 2 +- .../ConsoleInteractionServiceTests.cs | 4 +- 36 files changed, 368 insertions(+), 35 deletions(-) diff --git a/src/Aspire.Cli/Commands/InitCommand.cs b/src/Aspire.Cli/Commands/InitCommand.cs index 49a8af6276f..b34644644a5 100644 --- a/src/Aspire.Cli/Commands/InitCommand.cs +++ b/src/Aspire.Cli/Commands/InitCommand.cs @@ -147,6 +147,12 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell InteractionService.DisplayMessage(KnownEmojis.Information, $"Creating {languageInfo.DisplayName} AppHost..."); InteractionService.DisplayEmptyLine(); var polyglotResult = await CreatePolyglotAppHostAsync(languageInfo, cancellationToken); + if (polyglotResult != 0) + { + InteractionService.DisplayError(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, ExecutionContext.LogFilePath)); + return polyglotResult; + } + return await _agentInitCommand.PromptAndChainAsync(_hostEnvironment, InteractionService, polyglotResult, _executionContext.WorkingDirectory, cancellationToken); } @@ -181,6 +187,12 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell workspaceRoot = _executionContext.WorkingDirectory; } + if (initResult != 0) + { + InteractionService.DisplayError(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, ExecutionContext.LogFilePath)); + return initResult; + } + return await _agentInitCommand.PromptAndChainAsync(_hostEnvironment, InteractionService, initResult, workspaceRoot, cancellationToken); } diff --git a/src/Aspire.Cli/Commands/NewCommand.cs b/src/Aspire.Cli/Commands/NewCommand.cs index cc8d4f48c4a..b8b7e53eac2 100644 --- a/src/Aspire.Cli/Commands/NewCommand.cs +++ b/src/Aspire.Cli/Commands/NewCommand.cs @@ -3,6 +3,7 @@ using System.CommandLine; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Text.RegularExpressions; using Aspire.Cli.Configuration; using Aspire.Cli.Interaction; @@ -253,6 +254,7 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell if (!resolveResult.Success) { InteractionService.DisplayError(resolveResult.ErrorMessage); + InteractionService.DisplayError(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, ExecutionContext.LogFilePath)); return ExitCodeConstants.InvalidCommand; } @@ -270,6 +272,12 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell Language = template.LanguageId }; var templateResult = await template.ApplyTemplateAsync(inputs, parseResult, cancellationToken); + if (templateResult.ExitCode != 0) + { + InteractionService.DisplayError(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, ExecutionContext.LogFilePath)); + return templateResult.ExitCode; + } + if (templateResult.OutputPath is not null && ExtensionHelper.IsExtensionHost(InteractionService, out var extensionInteractionService, out _)) { extensionInteractionService.OpenEditor(templateResult.OutputPath); diff --git a/src/Aspire.Cli/Interaction/ConsoleInteractionService.cs b/src/Aspire.Cli/Interaction/ConsoleInteractionService.cs index 2329893d1ae..042af0d13e9 100644 --- a/src/Aspire.Cli/Interaction/ConsoleInteractionService.cs +++ b/src/Aspire.Cli/Interaction/ConsoleInteractionService.cs @@ -352,15 +352,24 @@ public void DisplaySuccess(string message, bool allowMarkup = false) public void DisplayLines(IEnumerable<(OutputLineStream Stream, string Line)> lines) { - foreach (var (stream, line) in lines) + var linesArray = lines.ToArray(); + + // Special case one stderr line to include error icon. + if (linesArray.Length == 1 && linesArray[0].Stream == OutputLineStream.StdErr) + { + DisplayError(linesArray[0].Line); + return; + } + + foreach (var (stream, line) in linesArray) { if (stream == OutputLineStream.StdOut) { - MessageConsole.MarkupLineInterpolated($"{line.EscapeMarkup()}"); + MessageConsole.MarkupLine(line.EscapeMarkup()); } else { - MessageConsole.MarkupLineInterpolated($"[red]{line.EscapeMarkup()}[/]"); + MessageConsole.MarkupLine($"[red]{line.EscapeMarkup()}[/]"); } } } diff --git a/src/Aspire.Cli/Resources/ErrorStrings.resx b/src/Aspire.Cli/Resources/ErrorStrings.resx index 5ae0e332b1c..89b3cb333ad 100644 --- a/src/Aspire.Cli/Resources/ErrorStrings.resx +++ b/src/Aspire.Cli/Resources/ErrorStrings.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. Invalid locale {0} provided will not be used. diff --git a/src/Aspire.Cli/Resources/InteractionServiceStrings.Designer.cs b/src/Aspire.Cli/Resources/InteractionServiceStrings.Designer.cs index ba32d8903a0..c383e3132bc 100644 --- a/src/Aspire.Cli/Resources/InteractionServiceStrings.Designer.cs +++ b/src/Aspire.Cli/Resources/InteractionServiceStrings.Designer.cs @@ -249,6 +249,15 @@ public static string ProjectCouldNotBeBuilt { } } + /// + /// Looks up a localized string similar to The app could not be created. See logs at {0}. + /// + public static string ProjectCouldNotBeCreated { + get { + return ResourceManager.GetString("ProjectCouldNotBeCreated", resourceCulture); + } + } + /// /// Looks up a localized string similar to The --apphost option specified a project that does not exist.. /// diff --git a/src/Aspire.Cli/Resources/InteractionServiceStrings.resx b/src/Aspire.Cli/Resources/InteractionServiceStrings.resx index d3e5a106d08..37147bc2a6a 100644 --- a/src/Aspire.Cli/Resources/InteractionServiceStrings.resx +++ b/src/Aspire.Cli/Resources/InteractionServiceStrings.resx @@ -188,6 +188,9 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The operation was canceled. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.cs.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.cs.xlf index a2b9f687411..77938ce40ae 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.cs.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.cs.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Rozhraní příkazového řádku Aspire vyžaduje sadu .NET SDK verze {0} nebo novější. Zjištěno: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Rozhraní příkazového řádku Aspire vyžaduje sadu .NET SDK verze {0} nebo novější. Zjištěno: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.de.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.de.xlf index 701c0a4bb35..105b147c3e3 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.de.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.de.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Die Aspire-CLI erfordert .NET SDK-Version {0} oder höher. Erkannt: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Die Aspire-CLI erfordert .NET SDK-Version {0} oder höher. Erkannt: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.es.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.es.xlf index 240b9a36fad..4d5f8cf401b 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.es.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.es.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - La CLI de Aspire requiere la versión {0} del SDK de .NET o posterior. Detectado: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + La CLI de Aspire requiere la versión {0} del SDK de .NET o posterior. Detectado: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.fr.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.fr.xlf index 49aa7980ca3..56f9826c225 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.fr.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.fr.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - L’interface CLI Aspire nécessite le kit SDK .NET version {0} ou ultérieure. A détecté : {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + L’interface CLI Aspire nécessite le kit SDK .NET version {0} ou ultérieure. A détecté : {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.it.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.it.xlf index b67c00d82e2..a1d09505fdf 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.it.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.it.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - L'interfaccia della riga di comando di Aspire richiede .NET SDK versione {0} o successiva. Rilevata: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + L'interfaccia della riga di comando di Aspire richiede .NET SDK versione {0} o successiva. Rilevata: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.ja.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.ja.xlf index bf3dd744aa7..4d92c05bc1b 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.ja.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.ja.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Aspire CLI には .NET SDK バージョン {0} 以降が必要です。以下を検出しました: {1}。 + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Aspire CLI には .NET SDK バージョン {0} 以降が必要です。以下を検出しました: {1}。 diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.ko.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.ko.xlf index e89d6027758..b2617db5734 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.ko.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.ko.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Aspire CLI를 사용하려면 .NET SDK 버전 {0} 이상이 필요합니다. 감지됨: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Aspire CLI를 사용하려면 .NET SDK 버전 {0} 이상이 필요합니다. 감지됨: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.pl.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.pl.xlf index 3a9f52e9a9b..0d331e08382 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.pl.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.pl.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Interfejs wiersza polecenia platformy Aspire wymaga zestawu .NET SDK w wersji {0} lub nowszej. Wykryto {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Interfejs wiersza polecenia platformy Aspire wymaga zestawu .NET SDK w wersji {0} lub nowszej. Wykryto {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.pt-BR.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.pt-BR.xlf index 8c72675d3f1..55fcf96dc60 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.pt-BR.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.pt-BR.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - A CLI do Aspire requer a versão do SDK do .NET {0} ou posterior. Detectado: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + A CLI do Aspire requer a versão do SDK do .NET {0} ou posterior. Detectado: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.ru.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.ru.xlf index 20ffddfee1c..e682bdce529 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.ru.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.ru.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Для Aspire CLI требуется версия .NET SDK {0} или более поздняя. Обнаружено: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Для Aspire CLI требуется версия .NET SDK {0} или более поздняя. Обнаружено: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.tr.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.tr.xlf index 65cc034b724..624cfe67e3d 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.tr.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.tr.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Aspire CLI için .NET SDK sürümünün {0} veya daha yeni olması gerekiyor. Algılanan: {1}. + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Aspire CLI için .NET SDK sürümünün {0} veya daha yeni olması gerekiyor. Algılanan: {1}. diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hans.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hans.xlf index c62c330ae6d..78a6d12a985 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hans.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hans.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Aspire CLI 需要 .NET SDK {0} 或更高版本。检测到: {1}。 + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Aspire CLI 需要 .NET SDK {0} 或更高版本。检测到: {1}。 diff --git a/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hant.xlf b/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hant.xlf index d7db47f3e19..f60118fd04c 100644 --- a/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hant.xlf +++ b/src/Aspire.Cli/Resources/xlf/ErrorStrings.zh-Hant.xlf @@ -123,8 +123,8 @@ - The Aspire CLI requires .NET SDK version {0} or later. Detected: {1}. - Aspire CLI 需要 .NET SDK 版本 {0} 或更新版本。已偵測到: {1}。 + C# apphost requires .NET SDK version {0} or later. Detected: {1}. + Aspire CLI 需要 .NET SDK 版本 {0} 或更新版本。已偵測到: {1}。 diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.cs.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.cs.xlf index d360fc1dd5b..78c357033e1 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.cs.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.cs.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. Parametr --apphost určil projekt, který neexistuje. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.de.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.de.xlf index d3813d780c2..d879fdae57f 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.de.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.de.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. Die Option „--apphost“ hat ein Projekt angegeben, das nicht vorhanden ist. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.es.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.es.xlf index 982157132e0..846190f3ee7 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.es.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.es.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. La opción --apphost especificó un proyecto que no existe. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.fr.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.fr.xlf index efc6b6bfe78..2513836bf4b 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.fr.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.fr.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. L’option --apphost spécifiait un projet qui n’existe pas. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.it.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.it.xlf index 87fb959659c..168dbc5df3e 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.it.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.it.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. L'opzione --apphost ha specificato un progetto che non esiste. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ja.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ja.xlf index a12909dd6ed..b3f4ff4dafe 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ja.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ja.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. --apphost オプションで、存在しないプロジェクトが指定されています。 diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ko.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ko.xlf index a0da6e95d88..17a361f3885 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ko.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ko.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. --apphost 옵션에서 존재하지 않는 프로젝트를 지정했습니다. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pl.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pl.xlf index 879ea125e22..86fb4b4e586 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pl.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pl.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. Opcja --apphost określiła projekt, który nie istnieje. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pt-BR.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pt-BR.xlf index c1e1c1fc147..17df36c6c4f 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pt-BR.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pt-BR.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. A opção --apphost especificou um projeto que não existe. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ru.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ru.xlf index e411dcd9d43..2b00672ca11 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ru.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ru.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. В параметре --apphost указан несуществующий проект. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.tr.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.tr.xlf index a2c5dcd70fb..dcae43c61f0 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.tr.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.tr.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. --apphost seçeneği var olmayan bir projeyi belirtti. diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hans.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hans.xlf index 3f57c4dbabb..7b277fb6aa3 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hans.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hans.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. --apphost 选项指定了不存在的项目。 diff --git a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hant.xlf b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hant.xlf index ed9de878af4..44ef6cbcf88 100644 --- a/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hant.xlf +++ b/src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hant.xlf @@ -102,6 +102,11 @@ The project could not be built. See logs at {0} + + The app could not be created. See logs at {0} + The app could not be created. See logs at {0} + + The --apphost option specified a project that does not exist. --apphost 選項指定的專案不存在。 diff --git a/tests/Aspire.Cli.Tests/Commands/InitCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/InitCommandTests.cs index a671db89691..53998e37f4f 100644 --- a/tests/Aspire.Cli.Tests/Commands/InitCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/InitCommandTests.cs @@ -1,10 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Globalization; using Aspire.Cli.Commands; using Aspire.Cli.Interaction; using Aspire.Cli.NuGet; using Aspire.Cli.Packaging; +using Aspire.Cli.Projects; +using Aspire.Cli.Resources; +using Aspire.Cli.Scaffolding; using Aspire.Cli.Tests.TestServices; using Aspire.Cli.Tests.Utils; using Microsoft.Extensions.DependencyInjection; @@ -543,6 +547,109 @@ public async Task InitCommandWithInvalidChannelShowsError() Assert.NotEqual(0, exitCode); } + [Fact] + public async Task InitCommand_WhenCSharpInitializationFails_DisplaysCreationErrorMessage() + { + TestInteractionService? testInteractionService = null; + + using var workspace = TemporaryWorkspace.Create(outputHelper); + + // Create a solution file only (no project files in the same directory) + var solutionFile = new FileInfo(Path.Combine(workspace.WorkspaceRoot.FullName, "Test.sln")); + File.WriteAllText(solutionFile.FullName, "Fake solution file"); + + var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper, options => + { + options.InteractionServiceFactory = (sp) => + { + testInteractionService = new TestInteractionService(); + return testInteractionService; + }; + + options.DotNetCliRunnerFactory = (sp) => + { + var runner = new TestDotNetCliRunner(); + runner.GetSolutionProjectsAsyncCallback = (_, _, _) => + { + return (0, Array.Empty()); + }; + runner.NewProjectAsyncCallback = (templateName, projectName, outputPath, invocationOptions, ct) => + { + return 1; // Simulate failure for C# template + }; + return runner; + }; + options.PackagingServiceFactory = (sp) => + { + return new TestPackagingService(); + }; + }); + + var serviceProvider = services.BuildServiceProvider(); + var initCommand = serviceProvider.GetRequiredService(); + + var parseResult = initCommand.Parse("init"); + var exitCode = await parseResult.InvokeAsync().DefaultTimeout(); + + var executionContext = serviceProvider.GetRequiredService(); + var expectedMessage = string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, executionContext.LogFilePath); + + Assert.NotEqual(0, exitCode); + Assert.NotNull(testInteractionService); + Assert.Contains(expectedMessage, testInteractionService.DisplayedErrors); + } + + [Fact] + public async Task InitCommand_WhenTypeScriptInitializationFails_DisplaysCreationErrorMessage() + { + TestInteractionService? testInteractionService = null; + + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper, options => + { + options.InteractionServiceFactory = (sp) => + { + testInteractionService = new TestInteractionService(); + return testInteractionService; + }; + + options.LanguageServiceFactory = (sp) => + { + var projectFactory = sp.GetRequiredService(); + var tsProject = projectFactory.GetProject(new LanguageInfo( + LanguageId: new LanguageId(KnownLanguageId.TypeScript), + DisplayName: "TypeScript (Node.js)", + PackageName: "@aspire/app-host", + DetectionPatterns: ["apphost.ts"], + CodeGenerator: "typescript", + AppHostFileName: "apphost.ts")); + return new TestLanguageService { DefaultProject = tsProject }; + }; + }); + + services.AddSingleton(new TestScaffoldingService + { + ScaffoldAsyncCallback = (context, cancellationToken) => + { + return Task.FromResult(false); // Simulate failure for TypeScript scaffolding + } + }); + + var serviceProvider = services.BuildServiceProvider(); + var initCommand = serviceProvider.GetRequiredService(); + + var parseResult = initCommand.Parse("init"); + var exitCode = await parseResult.InvokeAsync().DefaultTimeout(); + + var executionContext = serviceProvider.GetRequiredService(); + var expectedMessage = string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, executionContext.LogFilePath); + + Assert.NotEqual(0, exitCode); + Assert.NotNull(testInteractionService); + Assert.Contains(expectedMessage, testInteractionService.DisplayedErrors); + } + private sealed class TestPackagingServiceWithChannelTracking(Action onChannelUsed) : IPackagingService { public Task> GetChannelsAsync(CancellationToken cancellationToken = default) diff --git a/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs index d671a48055d..b46f070343c 100644 --- a/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Globalization; using Aspire.Cli.Utils; using Aspire.Cli.Certificates; using Aspire.Cli.Commands; @@ -1420,9 +1421,13 @@ public async Task NewCommandWithTypeScriptStarterReturnsFailedToBuildArtifactsWh var exitCode = await result.InvokeAsync().DefaultTimeout(); + var executionContext = provider.GetRequiredService(); + var expectedCreationError = string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, executionContext.LogFilePath); + Assert.Equal(ExitCodeConstants.FailedToBuildArtifacts, exitCode); - Assert.Single(interactionService.DisplayedErrors); - Assert.Equal("Automatic 'aspire restore' failed for the new TypeScript starter project. Run 'aspire restore' in the project directory for more details.", interactionService.DisplayedErrors[0]); + Assert.Collection(interactionService.DisplayedErrors, + error => Assert.Equal("Automatic 'aspire restore' failed for the new TypeScript starter project. Run 'aspire restore' in the project directory for more details.", error), + error => Assert.Equal(expectedCreationError, error)); } [Fact] @@ -1471,6 +1476,121 @@ public async Task NewCommandNonInteractiveDoesNotPrompt() var exitCode = await result.InvokeAsync().DefaultTimeout(); Assert.Equal(0, exitCode); } + + [Fact] + public async Task NewCommand_WhenCSharpTemplateApplyFails_DisplaysCreationErrorMessage() + { + TestInteractionService? testInteractionService = null; + + using var workspace = TemporaryWorkspace.Create(outputHelper); + var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper, options => + { + options.InteractionServiceFactory = (sp) => + { + testInteractionService = new TestInteractionService(); + return testInteractionService; + }; + + options.NewCommandPrompterFactory = (sp) => + { + var interactionService = sp.GetRequiredService(); + return new TestNewCommandPrompter(interactionService); + }; + + options.DotNetCliRunnerFactory = (sp) => + { + var runner = new TestDotNetCliRunner(); + runner.SearchPackagesAsyncCallback = (dir, query, prerelease, take, skip, nugetSource, useCache, options, cancellationToken) => + { + var package = new NuGetPackage() + { + Id = "Aspire.ProjectTemplates", + Source = "nuget", + Version = "9.2.0" + }; + + return (0, new NuGetPackage[] { package }); + }; + + runner.NewProjectAsyncCallback = (templateName, projectName, outputPath, invocationOptions, ct) => + { + return 1; // Simulate failure + }; + + return runner; + }; + }); + + var provider = services.BuildServiceProvider(); + + var command = provider.GetRequiredService(); + var result = command.Parse("new aspire-starter --use-redis-cache --test-framework None"); + + var exitCode = await result.InvokeAsync().DefaultTimeout(); + + var executionContext = provider.GetRequiredService(); + var expectedMessage = string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, executionContext.LogFilePath); + + Assert.NotEqual(0, exitCode); + Assert.NotNull(testInteractionService); + Assert.Contains(expectedMessage, testInteractionService.DisplayedErrors); + } + + [Fact] + public async Task NewCommand_WhenTypeScriptTemplateApplyFails_DisplaysCreationErrorMessage() + { + TestInteractionService? testInteractionService = null; + + using var workspace = TemporaryWorkspace.Create(outputHelper); + var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper, options => + { + options.InteractionServiceFactory = (sp) => + { + testInteractionService = new TestInteractionService(); + return testInteractionService; + }; + + options.DotNetCliRunnerFactory = (sp) => + { + var runner = new TestDotNetCliRunner(); + runner.SearchPackagesAsyncCallback = (dir, query, prerelease, take, skip, nugetSource, useCache, options, cancellationToken) => + { + var package = new NuGetPackage() + { + Id = "Aspire.ProjectTemplates", + Source = "nuget", + Version = "9.2.0" + }; + + return (0, new NuGetPackage[] { package }); + }; + + return runner; + }; + }); + + services.AddSingleton(new TestScaffoldingService + { + ScaffoldAsyncCallback = (context, cancellationToken) => + { + return Task.FromResult(false); // Simulate failure for TypeScript template + } + }); + + var provider = services.BuildServiceProvider(); + + var command = provider.GetRequiredService(); + var result = command.Parse("new aspire-ts-empty --name TestApp --output ."); + + var exitCode = await result.InvokeAsync().DefaultTimeout(); + + var executionContext = provider.GetRequiredService(); + var expectedMessage = string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.ProjectCouldNotBeCreated, executionContext.LogFilePath); + + Assert.NotEqual(0, exitCode); + Assert.NotNull(testInteractionService); + Assert.Contains(expectedMessage, testInteractionService.DisplayedErrors); + } } internal sealed class TestNewCommandPrompter(IInteractionService interactionService) : NewCommandPrompter(interactionService) diff --git a/tests/Aspire.Cli.Tests/DotNetSdkInstallerTests.cs b/tests/Aspire.Cli.Tests/DotNetSdkInstallerTests.cs index f7bf937ef07..3a6c5c61af9 100644 --- a/tests/Aspire.Cli.Tests/DotNetSdkInstallerTests.cs +++ b/tests/Aspire.Cli.Tests/DotNetSdkInstallerTests.cs @@ -167,7 +167,7 @@ public void ErrorMessage_Format_IsCorrect() "10.0.100", "(not found)"); - Assert.Equal("The Aspire CLI requires .NET SDK version 10.0.100 or later. Detected: (not found).", message); + Assert.Equal("C# apphost requires .NET SDK version 10.0.100 or later. Detected: (not found).", message); } [Fact] diff --git a/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs b/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs index 7af4fd94ab8..ee2829bbb78 100644 --- a/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs +++ b/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs @@ -123,8 +123,8 @@ public void DisplayLines_WithMarkupCharacters_DoesNotCauseMarkupParsingError() Assert.Null(exception); var outputString = output.ToString(); Assert.Contains("Command output with brackets", outputString); - // Square brackets get escaped to [[square]] when using EscapeMarkup() - Assert.Contains("Error output with [[square]] brackets", outputString); + // EscapeMarkup() escapes [ to [[ for Spectre's parser, but Spectre renders [[ back to literal [ + Assert.Contains("Error output with [square] brackets", outputString); } [Fact] From dee5e32ca9c565c3a5be09ed9933897398429acc Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Thu, 19 Mar 2026 01:37:49 +0000 Subject: [PATCH 09/49] Add right-click context menu on resource endpoint URLs (#15347) Add three context menu actions for endpoint URL tree items in the Running AppHosts tree view: - Copy URL to Clipboard - Open in External Browser - Open in Simple Browser Introduces EndpointUrlItem TreeItem subclass with contextValue 'endpointUrl' to enable context menu targeting, replacing the generic DetailItem for endpoint URLs. Fixes #15345 Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- extension/loc/xlf/aspire-vscode.xlf | 9 +++ extension/package.json | 33 +++++++++ extension/package.nls.json | 3 + extension/src/extension.ts | 5 +- extension/src/loc/strings.ts | 3 + .../src/views/AspireAppHostTreeProvider.ts | 73 ++++++++++--------- 6 files changed, 92 insertions(+), 34 deletions(-) diff --git a/extension/loc/xlf/aspire-vscode.xlf b/extension/loc/xlf/aspire-vscode.xlf index 298109933ac..4e54b113696 100644 --- a/extension/loc/xlf/aspire-vscode.xlf +++ b/extension/loc/xlf/aspire-vscode.xlf @@ -88,6 +88,9 @@ Controls what happens with the Aspire Dashboard when debugging starts. + + Copy URL + Create a new project @@ -301,6 +304,12 @@ Open global Aspire settings + + Open in External Browser + + + Open in Simple Browser + Open local Aspire settings diff --git a/extension/package.json b/extension/package.json index c8bfa42d072..52a46d94c47 100644 --- a/extension/package.json +++ b/extension/package.json @@ -262,6 +262,24 @@ "category": "Aspire", "icon": "$(terminal)" }, + { + "command": "aspire-vscode.copyEndpointUrl", + "title": "%command.copyEndpointUrl%", + "category": "Aspire", + "icon": "$(clippy)" + }, + { + "command": "aspire-vscode.openInExternalBrowser", + "title": "%command.openInExternalBrowser%", + "category": "Aspire", + "icon": "$(link-external)" + }, + { + "command": "aspire-vscode.openInSimpleBrowser", + "title": "%command.openInSimpleBrowser%", + "category": "Aspire", + "icon": "$(browser)" + }, { "command": "aspire-vscode.switchToGlobalView", "title": "%command.switchToGlobalView%", @@ -431,6 +449,21 @@ "command": "aspire-vscode.executeResourceCommand", "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource/", "group": "4_commands@1" + }, + { + "command": "aspire-vscode.copyEndpointUrl", + "when": "view == aspire-vscode.runningAppHosts && viewItem == endpointUrl", + "group": "1_clipboard@1" + }, + { + "command": "aspire-vscode.openInExternalBrowser", + "when": "view == aspire-vscode.runningAppHosts && viewItem == endpointUrl", + "group": "2_open@1" + }, + { + "command": "aspire-vscode.openInSimpleBrowser", + "when": "view == aspire-vscode.runningAppHosts && viewItem == endpointUrl", + "group": "2_open@2" } ] }, diff --git a/extension/package.nls.json b/extension/package.nls.json index 7bb56f0f28d..568f73a5b6e 100644 --- a/extension/package.nls.json +++ b/extension/package.nls.json @@ -127,6 +127,9 @@ "command.restartResource": "Restart", "command.viewResourceLogs": "View logs", "command.executeResourceCommand": "Execute resource command", + "command.copyEndpointUrl": "Copy URL", + "command.openInExternalBrowser": "Open in External Browser", + "command.openInSimpleBrowser": "Open in Simple Browser", "command.switchToGlobalView": "Show global apphosts", "command.switchToWorkspaceView": "Show workspace apphost", "command.installCliStable": "Install Aspire CLI (stable)", diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 19607b7ab4e..b35db7e988c 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -97,6 +97,9 @@ export async function activate(context: vscode.ExtensionContext) { const restartResourceRegistration = vscode.commands.registerCommand('aspire-vscode.restartResource', (element) => appHostTreeProvider.restartResource(element)); const viewResourceLogsRegistration = vscode.commands.registerCommand('aspire-vscode.viewResourceLogs', (element) => appHostTreeProvider.viewResourceLogs(element)); const executeResourceCommandRegistration = vscode.commands.registerCommand('aspire-vscode.executeResourceCommand', (element) => appHostTreeProvider.executeResourceCommand(element)); + const copyEndpointUrlRegistration = vscode.commands.registerCommand('aspire-vscode.copyEndpointUrl', (element) => appHostTreeProvider.copyEndpointUrl(element)); + const openInExternalBrowserRegistration = vscode.commands.registerCommand('aspire-vscode.openInExternalBrowser', (element) => appHostTreeProvider.openInExternalBrowser(element)); + const openInSimpleBrowserRegistration = vscode.commands.registerCommand('aspire-vscode.openInSimpleBrowser', (element) => appHostTreeProvider.openInSimpleBrowser(element)); // Set initial context for welcome view vscode.commands.executeCommand('setContext', 'aspire.noRunningAppHosts', true); @@ -104,7 +107,7 @@ export async function activate(context: vscode.ExtensionContext) { // Activate the data repository (starts workspace describe --follow; global polling begins when the panel is visible) dataRepository.activate(); - context.subscriptions.push(appHostTreeView, refreshRunningAppHostsRegistration, switchToGlobalViewRegistration, switchToWorkspaceViewRegistration, openDashboardRegistration, stopAppHostRegistration, stopResourceRegistration, startResourceRegistration, restartResourceRegistration, viewResourceLogsRegistration, executeResourceCommandRegistration, { dispose: () => { appHostTreeProvider.dispose(); dataRepository.dispose(); } }); + context.subscriptions.push(appHostTreeView, refreshRunningAppHostsRegistration, switchToGlobalViewRegistration, switchToWorkspaceViewRegistration, openDashboardRegistration, stopAppHostRegistration, stopResourceRegistration, startResourceRegistration, restartResourceRegistration, viewResourceLogsRegistration, executeResourceCommandRegistration, copyEndpointUrlRegistration, openInExternalBrowserRegistration, openInSimpleBrowserRegistration, { dispose: () => { appHostTreeProvider.dispose(); dataRepository.dispose(); } }); context.subscriptions.push(cliAddCommandRegistration, cliNewCommandRegistration, cliInitCommandRegistration, cliDeployCommandRegistration, cliPublishCommandRegistration, cliDoCommandRegistration, openTerminalCommandRegistration, configureLaunchJsonCommandRegistration); context.subscriptions.push(cliUpdateCommandRegistration, cliUpdateSelfCommandRegistration, settingsCommandRegistration, openLocalSettingsCommandRegistration, openGlobalSettingsCommandRegistration, runAppHostCommandRegistration, debugAppHostCommandRegistration); diff --git a/extension/src/loc/strings.ts b/extension/src/loc/strings.ts index d65d03d95f7..9df9e729ac9 100644 --- a/extension/src/loc/strings.ts +++ b/extension/src/loc/strings.ts @@ -97,3 +97,6 @@ export const cliFoundAtDefaultPath = (path: string) => vscode.l10n.t('Aspire CLI export const selectDirectoryTitle = vscode.l10n.t('Select directory'); export const selectFileTitle = vscode.l10n.t('Select file'); export const enterPipelineStep = vscode.l10n.t('Enter the pipeline step to execute'); + +// Endpoint URL context menu strings +export const copiedUrlToClipboard = (url: string) => vscode.l10n.t('Copied {0} to clipboard', url); diff --git a/extension/src/views/AspireAppHostTreeProvider.ts b/extension/src/views/AspireAppHostTreeProvider.ts index b98fc02ef5d..7c679176c1e 100644 --- a/extension/src/views/AspireAppHostTreeProvider.ts +++ b/extension/src/views/AspireAppHostTreeProvider.ts @@ -15,6 +15,7 @@ import { tooltipState, tooltipHealth, tooltipEndpoints, + copiedUrlToClipboard, } from '../loc/strings'; import { AppHostDataRepository, @@ -23,7 +24,7 @@ import { shortenPath, } from './AppHostDataRepository'; -type TreeElement = AppHostItem | DetailItem | ResourcesGroupItem | ResourceItem | WorkspaceResourcesItem; +type TreeElement = AppHostItem | DetailItem | EndpointUrlItem | ResourcesGroupItem | ResourceItem | WorkspaceResourcesItem; function sortResources(resources: ResourceJson[]): ResourceJson[] { return [...resources].sort((a, b) => { @@ -38,6 +39,11 @@ function appHostIcon(path?: string): vscode.ThemeIcon { return new vscode.ThemeIcon(icon, new vscode.ThemeColor('aspire.brandPurple')); } +function stripResourceSuffix(url: string): string { + const idx = url.indexOf('/?resource='); + return idx !== -1 ? url.substring(0, idx) : url; +} + class AppHostItem extends vscode.TreeItem { constructor(public readonly appHost: AppHostDisplayInfo) { const name = shortenPath(appHost.appHostPath); @@ -69,6 +75,20 @@ class DetailItem extends vscode.TreeItem { } } +class EndpointUrlItem extends vscode.TreeItem { + constructor(public readonly url: string, displayName: string) { + super(displayName, vscode.TreeItemCollapsibleState.None); + this.iconPath = new vscode.ThemeIcon('link-external'); + this.tooltip = url; + this.contextValue = 'endpointUrl'; + this.command = { + command: 'vscode.open', + title: url, + arguments: [vscode.Uri.parse(url)] + }; + } +} + class ResourcesGroupItem extends vscode.TreeItem { constructor(public readonly resources: ResourceJson[], public readonly appHostPid: number) { super(resourcesGroupLabel, vscode.TreeItemCollapsibleState.Expanded); @@ -215,7 +235,8 @@ export class AspireAppHostTreeProvider implements vscode.TreeDataProvider r.dashboardUrl)?.dashboardUrl ?? null; + const rawDashboardUrl = resources.find(r => r.dashboardUrl)?.dashboardUrl ?? null; + const dashboardUrl = rawDashboardUrl ? stripResourceSuffix(rawDashboardUrl) : null; return [new WorkspaceResourcesItem(resources, dashboardUrl, this._repository.workspaceAppHostPath, this._repository.workspaceAppHostName)]; } @@ -223,16 +244,7 @@ export class AspireAppHostTreeProvider implements vscode.TreeDataProvider !u.isInternal) ?? []; - return urls.map(url => new DetailItem( - url.displayName ?? url.url, - 'link-external', - url.url, - { - command: 'vscode.open', - title: url.url, - arguments: [vscode.Uri.parse(url.url)] - } - )); + return urls.map(url => new EndpointUrlItem(url.url, url.displayName ?? url.url)); } // ── Commands ── @@ -435,6 +429,19 @@ export class AspireAppHostTreeProvider implements vscode.TreeDataProvider { + await vscode.env.clipboard.writeText(element.url); + vscode.window.showInformationMessage(copiedUrlToClipboard(element.url)); + } + + openInExternalBrowser(element: EndpointUrlItem): void { + vscode.env.openExternal(vscode.Uri.parse(element.url)); + } + + openInSimpleBrowser(element: EndpointUrlItem): void { + vscode.commands.executeCommand('simpleBrowser.show', element.url); + } + private _runResourceCommand(element: ResourceItem, command: string, ...extraArgs: string[]): void { const suffix = extraArgs.length > 0 ? ` ${extraArgs.join(' ')}` : ''; From ec9a2ea8830f7e66bd0b778b32d3cdf954e1f990 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 18 Mar 2026 23:05:44 -0500 Subject: [PATCH 10/49] Add API Review Agent Skill (#15359) * Add API Review Agent Skill This skill allows us to automate parts of the API reviews that we do. * updates - tag the original author in the comment * Address PR review feedback on api-review skill - Fix description to say 'developer who introduced each API (via git blame)' instead of 'PR author' to avoid misdirected attribution - Replace broken gh api --jsonArray bash example with Python script using json.dump + gh api --input (--jsonArray is not a real gh flag) - Provide non-empty review body instead of empty string to avoid API rejection Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add deduplication check to api-review skill Before posting review comments, the skill now checks for existing API review comments by the current user on the PR. If found, it skips duplicates, updates changed findings, and only posts net-new findings. This prevents duplicate comments when the skill runs against the same PR multiple times. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/skills/api-review/SKILL.md | 504 +++++++++++++++++++++++++++++ AGENTS.md | 1 + 2 files changed, 505 insertions(+) create mode 100644 .github/skills/api-review/SKILL.md diff --git a/.github/skills/api-review/SKILL.md b/.github/skills/api-review/SKILL.md new file mode 100644 index 00000000000..3c14ae9fc53 --- /dev/null +++ b/.github/skills/api-review/SKILL.md @@ -0,0 +1,504 @@ +--- +name: api-review +description: Reviews .NET API surface area PRs for design guideline violations. Analyzes api/*.cs file diffs, applies review rules from .NET Framework Design Guidelines and Aspire conventions, and attributes findings to the developer who introduced each API (via git blame). Use this when asked to review API surface area changes. +--- + +You are a .NET API review specialist for the dotnet/aspire repository. Your goal is to review API surface area PRs — the auto-generated `api/*.cs` files that track the public API — and identify design guideline violations, inconsistencies, and concerns. + +## Background + +Aspire uses auto-generated API files at `src/*/api/*.cs` and `src/Components/*/api/*.cs` to track the public API surface. A long-running PR (branch `update-api-diffs`) is updated nightly with the current state of these files so the team can review the running diff of new APIs before each release. This skill reviews those PRs. + +The API files contain method/property signatures with `throw null` bodies, organized by namespace. Example: + +```csharp +namespace Aspire.Hosting +{ + public static partial class ResourceBuilderExtensions + { + public static IResourceBuilder WithEndpoint(this IResourceBuilder builder, int? port = null) where T : IResourceWithEndpoints { throw null; } + } +} +``` + +## Task Execution Steps + +### Step 1: Get the PR Diff + +Get the diff of API files from the PR. The user will provide a PR number or URL. + +```bash +GH_PAGER=cat gh pr diff --repo dotnet/aspire -- 'src/*/api/*.cs' 'src/Components/*/api/*.cs' > /tmp/api-diff.txt +``` + +If that doesn't work (the `--` path filter is not always supported), get the full diff and filter: + +```bash +GH_PAGER=cat gh pr diff --repo dotnet/aspire > /tmp/full-diff.txt +``` + +Then extract only the API file sections manually by looking for `diff --git a/src/*/api/*.cs` headers. + +### Step 2: Parse the Diff + +From the diff, identify: + +1. **New files** — entirely new API surface files (new packages) +2. **Added lines** — lines starting with `+` (not `+++`) represent new or changed APIs +3. **Removed lines** — lines starting with `-` (not `---`) represent removed APIs +4. **Changed files** — which `api/*.cs` files were modified + +Group the changes by assembly/package (the file path tells you: `src/Aspire.Hosting.Redis/api/Aspire.Hosting.Redis.cs` → package `Aspire.Hosting.Redis`). + +### Step 3: Apply Review Rules + +For each new or changed API, apply the following rules. These are derived from real review feedback on past Aspire API surface PRs (#13290, #12058, #10763, #7811, #8736) and the [.NET Framework Design Guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines/). + +--- + +#### Rule 1: Visibility & Surface Area Minimization + +**Question whether new public types and members need to be public.** + +Look for: +- New `public class` or `public interface` declarations that look like implementation details (e.g., annotations, internal helpers, DCP model types) +- Types whose names suggest internal usage (containing words like `Internal`, `Helper`, `Impl`, `Handler`) +- Types in packages marked with `SuppressFinalPackageVersion` (preview packages) get a lighter touch — note it but don't flag as error +- Public methods with no obvious external use case + +*Past example: "Why is this class public?" / "Does this need to be public? I only see 1 caller and that's in the same assembly." / "These are more like implementation detail and the main thing we needed was the publishing hooks"* + +Severity: **Warning** + +--- + +#### Rule 2: Experimental Attribute + +**New unstable APIs should be marked `[Experimental]`.** + +Look for: +- New public types or members that are only used by other Experimental APIs but lack `[Experimental]` themselves +- New APIs in emerging feature areas (publishing, deployment, pipelines, compute) without `[Experimental]` +- Reuse of existing experimental diagnostic IDs — each `[Experimental("ASPIREXXXX")]` ID must be unique. Check that new experimental attributes don't reuse IDs already in the codebase + +*Past example: "Should this be Experimental?" / "Does the InputsDialogValidationContext need an Experimental attribute on it? The only place it is used is Experimental." / "These shouldn't reuse ASPIRECOMPUTE001 — that was already taken"* + +Severity: **Warning** + +--- + +#### Rule 3: Naming Conventions + +**Names must follow .NET naming guidelines and Aspire conventions.** + +Check for: +- **Method names must be verbs or verb phrases**: `GetSecret`, `CreateBuilder`, `AddResource` — not nouns. Flag methods like `ExecutionConfigurationBuilder()` that should be `CreateExecutionConfigurationBuilder()` +- **Type names must be nouns or noun phrases**: Classes, structs, interfaces should not start with verbs. Flag names like `CreateContainerFilesAnnotation` → should be `ContainerFilesCallbackAnnotation` +- **Consistent naming across similar APIs**: The codebase has established patterns. Flag inconsistencies: + - Property for URI-type values: should be `UriExpression` (not `ServiceUri`, `Endpoint`, or `Uri` inconsistently) + - `IServiceProvider`-typed properties: should be named `Services` (not `ServiceProvider`) — 25 uses of `Services` vs 10 of `ServiceProvider` in the codebase + - Port-related methods: `WithHostPort` or `WithGatewayPort` (not `WithHttpPort` — only one instance exists) +- **Interface names must match implementing class patterns**: If the class is `AzureKeyVaultResource`, the interface should be `IAzureKeyVaultResource` (not `IKeyVaultResource`) +- **Avoid confusingly similar names**: Flag pairs like `PipelineStepExtensions` / `PipelineStepsExtensions` (differ only by an 's') +- **Extension class placement**: Static factory methods like `Create*` should be on the type itself (e.g., `ParameterResource.Create()`), not in unrelated extension classes +- **PascalCase** for all public members +- **`I`-prefix** for all interfaces + +*Past examples: "The naming here gives me Java feels" / "This method name isn't a verb" / "UriExpression to be consistent" / "Why is this ContainerRegistryInfo and not ContainerRegistry?" / "We call this WithHostPort everywhere else"* + +Severity: **Warning** (naming inconsistency), **Error** (violates .NET guidelines) + +--- + +#### Rule 4: Namespace Placement + +**Types must be in appropriate, established namespaces.** + +Check for: +- Types in the global namespace (no `namespace` declaration) — always an error +- Public types in namespaces containing `Internal`, `Dcp`, or `Impl` — these are internal implementation namespaces +- Types in a different namespace than related types in the same assembly (e.g., a resource class in `Aspire.Hosting.Azure.AppService` when all others are in `Aspire.Hosting.Azure`) +- New namespaces being introduced without clear justification — prefer using existing namespaces +- Types in `Aspire.Hosting.Utils` or other utility namespaces — prefer `Aspire.Hosting.ApplicationModel` or the assembly's primary namespace + +*Past examples: "This should be in the same namespace as the rest of the resource classes" / "'Internal' namespace and public?" / "looks like this is the only type in Aspire.Hosting.Utils — is there a better namespace?" / "Missing a namespace on this type"* + +Severity: **Error** (no namespace / Internal namespace), **Warning** (inconsistent namespace) + +--- + +#### Rule 5: Parameter Design + +**Methods should have clean, versionable parameter lists.** + +Check for: +- **Too many optional parameters** (>5): These are extremely hard to version — suggest introducing an options/settings class. Flag the specific method and parameter count. + *Past example: "These APIs have way too many parameters. It might be cleaner to encapsulate some of these parameters into a specific options object" / "optional parameters at this scale are extremely hard to version — WithEndpoint is in the exact same jail"* +- **Redundant nullable default**: If a method has `string? publisherName = null` but a parameterless overload already exists, the `= null` is unnecessary and creates ambiguity +- **Inconsistent nullability**: Similar methods across the codebase should have consistent nullability. For example, if `WithHostPort(int? port)` is used everywhere else, a new `WithHostPort(int port)` is inconsistent +- **Boolean parameters**: Prefer enums over `bool` parameters for better readability and future extensibility + +Severity: **Warning** (too many params, bool params), **Error** (inconsistent nullability across same-named methods) + +--- + +#### Rule 6: Type Design + +**Types must follow .NET type design guidelines.** + +Check for: +- **`record struct` in public API**: Adding fields later is a binary breaking change. Flag and suggest using `record class` or `class` instead if the type may evolve + *Past example: "Does this need to be a record struct?" / discussion about binary breaking changes from adding fields* +- **`Tuple<>` in public API**: Never use tuples in public return types or parameters. Use dedicated types. + *Past example: "Using a Tuple in public API isn't the best — can the exception go on the interface?"* +- **Public fields**: Should be properties instead. Exception: `const` fields are fine. +- **`static readonly` that could be `const`**: String and primitive `static readonly` fields should typically be `const` + *Past example: "Why do we sometimes use static readonly and sometimes const?" — resolved by making all const* +- **Enum with `None` not at 0**: If an enum has a `None` or default member, it should be value 0 + *Past example: "Having None not be 0 is sort of odd"* +- **Missing sealed**: New public classes should be `sealed` unless extensibility is explicitly intended + +Severity: **Warning** + +--- + +#### Rule 7: Breaking Changes + +**Detect potentially breaking API changes.** + +Check for: +- Parameter nullability changes (nullable → non-nullable or vice versa) +- Removed public members from types or interfaces +- Changed base class or added new base class (may be binary breaking) +- Changed return types + +Severity: **Error** + +--- + +#### Rule 8: Consistency with Established Patterns + +**New APIs should follow patterns established elsewhere in the codebase.** + +Check for: +- **Resource types**: Should they implement `IResourceWithParent` if they have a parent relationship? +- **Emulator resources**: Should follow the same property/method patterns as existing emulators +- **Builder extension methods**: Must return `IResourceBuilder` for fluent chaining (or `IDistributedApplicationBuilder` for non-resource methods) +- **Connection properties**: Resources implementing `IResourceWithConnectionString` should expose consistent properties +- **AddPublisher/AddResource pattern**: `Add*` methods on `IDistributedApplicationBuilder` should return the builder for chaining + +*Past example: "AddPublisher should return IDistributedApplicationBuilder" / "Other emulator resources don't have this property" / "Other Resources don't have an IServiceProvider"* + +Severity: **Warning** + +--- + +#### Rule 9: Preview Package Awareness + +**New packages should ship as preview initially.** + +Check for: +- Entirely new API files (new assemblies) — note whether the package is likely preview or stable +- Brand new packages shipping as stable without sufficient bake time + +*Past example: "This new package is set to ship as stable for 9.2. Is that intentional?" / "I think preview" / "all brand new packages/integrations we are adding this release are set to stay in preview"* + +Severity: **Info** + +--- + +#### Rule 10: Obsolete API Hygiene + +**Obsolete APIs in preview packages are unnecessary overhead.** + +Check for: +- `[Obsolete]` attributes on APIs in packages that haven't shipped stable yet — these can just be renamed/removed directly +- `[EditorBrowsable(EditorBrowsableState.Never)]` combined with `[Obsolete]` in preview packages + +*Past example: "This library is in preview mode. Do we need Obsolete/EBS.Never properties? Can we just change the names in the major version?"* + +Severity: **Info** + +--- + +### Step 4: Git Attribution (REQUIRED before posting) + +**Every finding MUST include author attribution before posting to the PR.** This is critical — it routes feedback to the right person and ensures accountability. + +For each finding, identify who introduced the API change using `git blame` on the **source file** (not the auto-generated `api/*.cs` file). + +#### 4a: Find the source file + +The API files at `src/*/api/*.cs` are auto-generated. To find the actual source, search for the class/method name in the non-API source files: + +```bash +# Find the source file for a given API (e.g., WithRemoteImageName) +git grep -rn "WithRemoteImageName" -- "src/**/*.cs" ":!src/*/api/*.cs" | head -5 +``` + +#### 4b: Blame the source file + +Once you have the source file and line number, use `git blame` to find the author: + +```bash +# Get the author of a specific line +git blame -L , --porcelain | grep -E "^author |^author-mail " +``` + +Run blame in batch for efficiency — collect all source file locations first, then blame them all at once. + +#### 4c: Map email to GitHub username + +Common Aspire contributors and their GitHub usernames: +- `mitch@mitchdeny.com` → `@mitchdenny` +- `eric.erhardt@microsoft.com` → `@eerhardt` +- `davidfowl@gmail.com` → `@davidfowl` +- `james@newtonking.com` → `@JamesNK` +- `sebastienros@gmail.com` → `@sebastienros` + +For unknown emails, look up the commit on GitHub: + +```bash +GH_PAGER=cat gh api "/repos/dotnet/aspire/commits/" --jq '.author.login // .commit.author.name' +``` + +#### 4d: Format attribution + +Prepend each review comment body with `cc @username` on its own line, followed by a blank line before the finding text. Example: + +``` +cc @username + +❌ **[Breaking Change]** Description of the issue... +``` + +**Do not skip this step.** If you cannot determine the author, use the git log pickaxe search as a fallback: + +```bash +git log main -S "" --pretty=format:"%H|%an|%ae|%s" -- "src/**/*.cs" ":!src/*/api/*.cs" | head -5 +``` + +### Step 5: Generate Review Report + +Present findings in a structured format, grouped by severity: + +```markdown +## API Review Findings + +### ❌ Errors (must fix before release) + +| # | File | API | Rule | Issue | Author | +|---|------|-----|------|-------|--------| +| 1 | Aspire.Hosting.cs | `SomeType` | Namespace | Type in global namespace | @user (abc1234) | + +### ⚠️ Warnings (should address) + +| # | File | API | Rule | Issue | Author | +|---|------|-----|------|-------|--------| +| 1 | Aspire.Hosting.cs | `WithFoo(...)` | Parameters | 8 optional params — consider options object | @user (def5678) | + +### ℹ️ Info (consider) + +| # | File | API | Rule | Issue | Author | +|---|------|-----|------|-------|--------| +| 1 | Aspire.Hosting.NewPkg.cs | (entire file) | Preview | New package — verify shipping as preview | @user (ghi9012) | + +### Summary +- **X errors**, **Y warnings**, **Z info** across N files +- Top areas of concern: [list] +``` + +### Step 6: Post Review Comments on the PR + +After generating the report, **post each finding as a separate PR review comment** so the team can discuss each one independently. + +#### Check for existing reviews (deduplication) + +Before posting, check whether you have already posted a review on this PR. If so, **update or skip rather than duplicate**. + +```python +# check_existing_reviews.py — detect prior API review comments +import subprocess, json, os + +env = {**os.environ, 'GH_PAGER': 'cat'} + +# Get the current authenticated user +result = subprocess.run(['gh', 'api', '/user', '--jq', '.login'], + capture_output=True, text=True, env=env) +current_user = result.stdout.strip() + +# Fetch all review comments on the PR by the current user +result = subprocess.run([ + 'gh', 'api', '--paginate', + '/repos/dotnet/aspire/pulls//comments' +], capture_output=True, text=True, encoding='utf-8', env=env) +all_comments = json.loads(result.stdout) + +my_comments = [c for c in all_comments if c['user']['login'] == current_user] +api_review_comments = [c for c in my_comments + if any(marker in c['body'] for marker in + ['[Breaking Change]', '[Parameter Design]', '[Namespace', + '[Visibility]', '[Type Design]', '[Preview Package]', + '[Obsolete API', '[Naming', '[Experimental', '[Consistency'])] + +if api_review_comments: + print(f"Found {len(api_review_comments)} existing API review comments by @{current_user}") + for c in api_review_comments: + print(f" - {c['id']}: {c['path']}:{c.get('line', '?')} | {c['body'][:60]}...") +else: + print("No existing API review comments found — safe to post.") +``` + +**If existing comments are found:** +1. Compare each new finding against existing comments (match by file path + rule name) +2. **Skip** findings that already have a matching comment +3. **Update** existing comments (via `PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id}`) if the finding text has changed +4. **Post only net-new** findings that don't have a matching existing comment + +**If no existing comments are found**, proceed to post all findings. + +#### Determine line numbers for inline comments + +For each finding, determine the line number in the diff where the API appears. Parse the diff hunks from Step 1 to map API declarations to their line numbers in the changed files. + +```bash +# Get the diff with line numbers to map findings to positions +GH_PAGER=cat gh pr diff --repo dotnet/aspire > /tmp/full-diff.txt +``` + +For each added API line (starting with `+`), count its position within the diff hunk to determine the diff-relative line number. + +#### Post each finding as a separate inline review comment + +Each violation gets its own comment so it can be discussed independently. **Every comment MUST include the `cc @username` attribution from Step 4.** Do not post comments without attribution. + +Use the GitHub API to post individual review comments on the specific lines. Build the JSON payload using Python to avoid encoding issues (see Constraint #9), then post with `gh api --input`: + +```python +# build_review.py — construct the review JSON and post it +import json, subprocess, os + +pr_head_sha = "" # from: gh pr view --json headRefOid --jq '.headRefOid' + +review = { + "commit_id": pr_head_sha, + "event": "COMMENT", + "body": "API review findings — see inline comments for details.", + "comments": [ + { + "path": "src/Aspire.Hosting/api/Aspire.Hosting.cs", + "line": 42, + "side": "RIGHT", + "body": "cc @username\n\n⚠️ **[Parameter Design]** `AllowInbound` has 6 optional parameters — consider introducing an options class.\n\nRef: [Parameter Design Guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines/parameter-design)" + }, + { + "path": "src/Aspire.Hosting.Azure.Network/api/Aspire.Hosting.Azure.Network.cs", + "line": 15, + "side": "RIGHT", + "body": "cc @username\n\nℹ️ **[Preview Package]** Entirely new package — verify it is shipping as preview (SuppressFinalPackageVersion=true)." + } + ] +} + +tmpfile = os.path.join(os.environ.get('TEMP', '/tmp'), 'review.json') +with open(tmpfile, 'w', encoding='utf-8') as f: + json.dump(review, f, ensure_ascii=False) + +subprocess.run([ + 'gh', 'api', '--method', 'POST', + '/repos/dotnet/aspire/pulls//reviews', + '--input', tmpfile +], env={**os.environ, 'GH_PAGER': 'cat'}) +``` + +Each comment in the `comments` array becomes a **separate review thread** on the PR, allowing independent discussion. + +**Comment format for each finding:** + +``` +cc @username + +[severity emoji] **[Rule Name]** Description of the issue. + +Ref: [Guideline link](url) +``` + +The `cc @username` line MUST be the first line of every comment. This tags the original author of the API so they get notified. + +Severity emojis: ❌ Error, ⚠️ Warning, ℹ️ Info + +**Note on `side` field**: Always include `"side": "RIGHT"` for comments on added lines (the new file version). + +#### Fallback: file-level comments + +If a finding applies to an entire new file (e.g., "new package — verify preview status") or the exact line cannot be determined, post an inline comment on line 1 of the file: + +```bash +{ + "path": "src/Aspire.Hosting.NewPkg/api/Aspire.Hosting.NewPkg.cs", + "line": 1, + "side": "RIGHT", + "body": "cc @username\n\nℹ️ **[Preview Package]** ..." +} +``` + +**Note**: Do NOT use `"subject_type": "file"` — the GitHub PR reviews API does not support this field. Always use `"line": 1` with `"side": "RIGHT"` instead. + +#### Post a summary comment at the end + +After all inline comments are posted, post a single top-level summary comment on the PR: + +```bash +GH_PAGER=cat gh pr comment --repo dotnet/aspire --body "## API Review Summary + +**X errors**, **Y warnings**, **Z info** across N files. + +Top areas of concern: +- [list key themes] + +Each finding is posted as a separate inline comment for discussion." +``` + +#### Ask before posting + +Before posting, show the user the list of comments that will be posted (including author attributions) and ask for confirmation. Do not post without approval. + +## Important Constraints + +1. **Only review `api/*.cs` files** — these are the source of truth for public API surface +2. **Focus on added/changed lines** — don't review existing APIs that haven't changed +3. **Check both sides of a rename** — if an API was removed and a similar one added, it's likely a rename, not a removal + addition +4. **Be pragmatic** — APIs in preview packages (`SuppressFinalPackageVersion`) get lighter scrutiny +5. **Don't flag auto-generated formatting** — the API tool controls formatting; only review API design +6. **Cross-reference related files** — when questioning visibility, check if the type is used in other Aspire assemblies (which would require it to be public) +7. **Attribute to the right person** — search source code history, not API file history (API files are auto-generated). Use `git blame` on the actual source `.cs` files. Every comment MUST tag the original author with `cc @username` as the first line. +8. **Include `side: "RIGHT"` in all review comments** — the GitHub API requires this for inline comments on added lines +9. **Use Python (not PowerShell) for building JSON payloads** — PowerShell's `ConvertTo-Json | Out-File` mangles multi-byte Unicode characters (emojis like ❌ ⚠️ ℹ️ and em-dashes — become mojibake). Always use Python's `json.dumps(ensure_ascii=False)` with `open(file, 'w', encoding='utf-8')` when constructing JSON for the GitHub API. + +## Reference: .NET Framework Design Guidelines + +The rules above are grounded in Microsoft's official guidelines at: +- [Framework Design Guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines/) +- [Naming Guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines/naming-guidelines) +- [Type Design Guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines/type) +- [Member Design Guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines/member) +- [Parameter Design](https://learn.microsoft.com/dotnet/standard/design-guidelines/parameter-design) +- [Designing for Extensibility](https://learn.microsoft.com/dotnet/standard/design-guidelines/designing-for-extensibility) +- [.NET Breaking Change Rules](https://learn.microsoft.com/dotnet/core/compatibility/library-change-rules) + +## Reference: Aspire-Specific Conventions + +These conventions are specific to the Aspire codebase, learned from past API reviews: + +| Convention | Example | Notes | +|-----------|---------|-------| +| URI properties named `UriExpression` | `public ReferenceExpression UriExpression` | Not `ServiceUri`, `Endpoint`, `Uri` | +| IServiceProvider property named `Services` | `public IServiceProvider Services` | Not `ServiceProvider` (25 vs 10 usage) | +| Port methods accept nullable | `WithHostPort(int? port)` | Allows random port assignment | +| Enums: None/default = 0 | `None = 0, Append = 1` | Not `Append = 0, None = 1` | +| Builder methods return builder | `IResourceBuilder` return | For fluent chaining | +| Extension static factories → type statics | `ParameterResource.Create()` | Not `ParameterResourceBuilderExtensions.Create()` | +| New packages ship preview | `true` | Until sufficient bake time | +| No Obsolete in preview packages | Just rename/remove directly | Don't add migration overhead | +| Resource types use established namespaces | `Aspire.Hosting.Azure` | Not sub-namespaces per resource | +| `const` over `static readonly` for strings | `public const string Tag = "8.6"` | Unless runtime computation needed | diff --git a/AGENTS.md b/AGENTS.md index e9134a200ea..a3fe3f7e3d6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -372,6 +372,7 @@ The following specialized skills are available in `.github/skills/`: - **test-management**: Quarantines or disables flaky/problematic tests using the QuarantineTools utility - **connection-properties**: Expert for creating and improving Connection Properties in Aspire resources - **dependency-update**: Guides dependency version updates by checking nuget.org, triggering the dotnet-migrate-package Azure DevOps pipeline, and monitoring runs +- **api-review**: Reviews .NET API surface area PRs for design guideline violations, applies rules from .NET Framework Design Guidelines and Aspire conventions, and attributes findings to the author who introduced each API ## Pattern-Based Instructions From 12532e0979737e7e8cedbc6aa378f81d43a8afa5 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Thu, 19 Mar 2026 04:07:02 +0000 Subject: [PATCH 11/49] [release/13.2] Fix legacy settings migration path adjustment for appHostPath (#15352) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix legacy settings migration path adjustment When migrating from .aspire/settings.json to aspire.config.json, the appHostPath was copied verbatim. But .aspire/settings.json stores paths relative to the .aspire/ directory (e.g., '../src/apphost.ts'), while aspire.config.json stores paths relative to its own directory (the project root). This caused the migrated path to resolve incorrectly. The fix re-bases the appHostPath during migration: resolves it against the legacy .aspire/ directory, then makes it relative to the config directory. For example, '../src/apphost.ts' becomes 'src/apphost.ts'. Includes unit tests for the path adjustment and an E2E test that verifies the full migration scenario with a TypeScript apphost in a subdirectory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix E2E test: use grep instead of terminal buffer check The terminal buffer accumulates all output, so the earlier echo of legacy settings.json content (containing '../src/apphost.ts') would cause false matches when verifying the migrated aspire.config.json. Use 'grep' with the exact JSON key-value pattern to isolate the check, and rely on the host-side file verification as the primary assertion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix E2E test: keep TS project intact, use robust patterns The previous test moved apphost.ts to src/ but left .modules/ in the workspace root, breaking TS imports. aspire run couldn't start, so the migration never triggered and aspire.config.json was never created. Changes: - Keep apphost.ts at workspace root (project stays valid) - Test re-basing with '../apphost.ts' -> 'apphost.ts' instead (same code path as '../src/apphost.ts' -> 'src/apphost.ts') - Wait for 'Press CTRL+C' or 'Apphost failed' instead of generic 'ERR:' which could false-match shell prompt patterns Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix E2E test: poll host filesystem instead of parsing terminal Previous approach failed because: 1. aspire run error messages varied by failure mode 2. Terminal buffer pattern matching was fragile across exit codes Now polls the host-side filesystem via bind mount for aspire.config.json, which is created during apphost discovery before the actual run attempt. This works regardless of whether aspire run succeeds or fails. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR feedback: normalize separators, guard empty paths, add tests - Normalize backslash separators to OS-native before Path operations, then always output forward slashes (matching storage convention) - Guard against empty/whitespace paths to avoid converting '' to '.' - Use { Length: > 0 } pattern match instead of separate null check - Rename misleading test to clarify .aspire/-relative semantics - Add tests: backslash normalization, output always uses '/', deeply nested paths, empty path preservation, null path handling Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Replace unrealistic test with realistic subdirectory path scenario The previous test used 'apphost.ts' without '../' prefix, which would mean the apphost lives inside .aspire/ — an impossible real-world scenario. Replace with a realistic .csproj-in-subdirectory case: '../MyApp.AppHost/MyApp.AppHost.csproj' -> 'MyApp.AppHost/MyApp.AppHost.csproj' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use PathNormalizer for migration path re-basing Replace manual slash normalization + GetFullPath with the existing PathNormalizer.NormalizePathForCurrentPlatform() utility, which does the same thing in one call. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add NormalizePathForStorage helper and additional path tests Address review feedback: - Extract PathNormalizer.NormalizePathForStorage() for the common backslash-to-forward-slash normalization used when persisting paths. - Add tests for ./path, bare relative path, Unix rooted, and Windows rooted legacy migration scenarios. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use realistic paths in migration tests Avoid test paths that imply apphost lives under .aspire/ since that never happens in practice. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Configuration/AspireConfigFile.cs | 15 + src/Shared/PathNormalizer.cs | 9 + .../LocalConfigMigrationTests.cs | 116 ++++++++ .../Configuration/AspireConfigFileTests.cs | 270 ++++++++++++++++++ 4 files changed, 410 insertions(+) create mode 100644 tests/Aspire.Cli.EndToEnd.Tests/LocalConfigMigrationTests.cs diff --git a/src/Aspire.Cli/Configuration/AspireConfigFile.cs b/src/Aspire.Cli/Configuration/AspireConfigFile.cs index 04297af42c9..985df60c602 100644 --- a/src/Aspire.Cli/Configuration/AspireConfigFile.cs +++ b/src/Aspire.Cli/Configuration/AspireConfigFile.cs @@ -7,6 +7,7 @@ using System.Text.Json.Serialization; using Aspire.Cli.Resources; using Aspire.Cli.Utils; +using Aspire.Hosting.Utils; using Microsoft.Extensions.Logging; namespace Aspire.Cli.Configuration; @@ -174,6 +175,20 @@ public static AspireConfigFile LoadOrCreate(string directory, string? defaultSdk var profiles = ReadApphostRunProfiles(Path.Combine(directory, "apphost.run.json")); config = FromLegacy(legacyConfig, profiles); + // Legacy .aspire/settings.json stores appHostPath relative to the .aspire/ directory, + // but aspire.config.json stores it relative to the config file's own directory (the parent + // of .aspire/). Re-base the path so it resolves correctly from the new location. + // Paths are always stored with '/' separators regardless of platform, but we normalize + // to the OS separator for Path operations and back to '/' for storage. + if (config.AppHost?.Path is { Length: > 0 } migratedPath && !Path.IsPathRooted(migratedPath)) + { + var legacySettingsDir = Path.Combine(directory, AspireJsonConfiguration.SettingsFolder); + var absolutePath = PathNormalizer.NormalizePathForCurrentPlatform( + Path.Combine(legacySettingsDir, migratedPath)); + config.AppHost.Path = PathNormalizer.NormalizePathForStorage( + Path.GetRelativePath(directory, absolutePath)); + } + // Persist the migrated config (legacy files are kept for older CLI versions) config.Save(directory); } diff --git a/src/Shared/PathNormalizer.cs b/src/Shared/PathNormalizer.cs index 419ad899e02..090657f20ba 100644 --- a/src/Shared/PathNormalizer.cs +++ b/src/Shared/PathNormalizer.cs @@ -17,4 +17,13 @@ public static string NormalizePathForCurrentPlatform(string path) return Path.GetFullPath(path); } + + /// + /// Normalizes a path for storage in configuration files by replacing + /// backslash separators with forward slashes. + /// + public static string NormalizePathForStorage(string path) + { + return path.Replace('\\', '/'); + } } diff --git a/tests/Aspire.Cli.EndToEnd.Tests/LocalConfigMigrationTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/LocalConfigMigrationTests.cs new file mode 100644 index 00000000000..ffbf5300d36 --- /dev/null +++ b/tests/Aspire.Cli.EndToEnd.Tests/LocalConfigMigrationTests.cs @@ -0,0 +1,116 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Cli.EndToEnd.Tests.Helpers; +using Aspire.Cli.Tests.Utils; +using Hex1b.Automation; +using Hex1b.Input; +using Xunit; + +namespace Aspire.Cli.EndToEnd.Tests; + +/// +/// End-to-end tests verifying that legacy .aspire/settings.json files with relative paths +/// are correctly migrated to aspire.config.json with adjusted paths. +/// +/// +/// When .aspire/settings.json stores appHostPath relative to the .aspire/ directory +/// (e.g., "../apphost.ts"), the migration to aspire.config.json must re-base the path +/// to be relative to the config file's own directory (e.g., "apphost.ts"). +/// +public sealed class LocalConfigMigrationTests(ITestOutputHelper output) +{ + /// + /// Verifies that migrating a legacy .aspire/settings.json with a "../apphost.ts" path + /// produces an aspire.config.json with the correct "apphost.ts" relative path. + /// + /// + /// + /// This scenario reproduces the bug where FromLegacy() copied appHostPath verbatim, + /// without adjusting from .aspire/-relative to project-root-relative. + /// + /// + /// The test keeps the TS project intact (apphost.ts at root with .modules/) so that + /// aspire run can actually start successfully. The re-basing logic "../apphost.ts" → + /// "apphost.ts" exercises the same code path as "../src/apphost.ts" → "src/apphost.ts". + /// + /// + [Fact] + public async Task LegacySettingsMigration_AdjustsRelativeAppHostPath() + { + var repoRoot = CliE2ETestHelpers.GetRepoRoot(); + var installMode = CliE2ETestHelpers.DetectDockerInstallMode(repoRoot); + var workspace = TemporaryWorkspace.Create(output); + + using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal( + repoRoot, installMode, output, + variant: CliE2ETestHelpers.DockerfileVariant.Polyglot, + mountDockerSocket: true, + workspace: workspace); + + var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken); + + var counter = new SequenceCounter(); + var auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500)); + + await auto.PrepareDockerEnvironmentAsync(counter, workspace); + await auto.InstallAspireCliInDockerAsync(installMode, counter); + + // Step 1: Create a valid TypeScript AppHost using aspire init. + // This produces apphost.ts, .modules/, aspire.config.json, etc. + await auto.TypeAsync("aspire init"); + await auto.EnterAsync(); + await auto.WaitUntilTextAsync("Which language would you like to use?", timeout: TimeSpan.FromSeconds(30)); + await auto.DownAsync(); + await auto.WaitUntilTextAsync("> TypeScript (Node.js)", timeout: TimeSpan.FromSeconds(5)); + await auto.EnterAsync(); + await auto.WaitUntilTextAsync("Created apphost.ts", timeout: TimeSpan.FromMinutes(2)); + await auto.DeclineAgentInitPromptAsync(counter); + + // Step 2: Replace aspire.config.json with a legacy .aspire/settings.json. + // The legacy format stores appHostPath relative to the .aspire/ directory, + // so "../apphost.ts" points up from .aspire/ to the workspace root where + // apphost.ts lives. The project files stay in place so aspire run can work. + await auto.TypeAsync("rm -f aspire.config.json"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + + var legacySettingsJson = """{"appHostPath":"../apphost.ts","language":"typescript/nodejs","sdkVersion":"13.2.0","channel":"staging"}"""; + await auto.TypeAsync($"mkdir -p .aspire && echo '{legacySettingsJson}' > .aspire/settings.json"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + + // Step 3: Run aspire run to trigger the migration from .aspire/settings.json + // to aspire.config.json. The migration happens during apphost discovery, + // before the actual build/run step. + await auto.TypeAsync("aspire run"); + await auto.EnterAsync(); + + // The migration creates aspire.config.json during apphost discovery, before + // the actual run. Poll the host-side filesystem via the bind mount rather + // than parsing terminal output, which is fragile across different failure modes. + var configPath = Path.Combine(workspace.WorkspaceRoot.FullName, "aspire.config.json"); + var deadline = DateTime.UtcNow.AddMinutes(3); + while (!File.Exists(configPath) && DateTime.UtcNow < deadline) + { + await Task.Delay(TimeSpan.FromSeconds(1), TestContext.Current.CancellationToken); + } + + // Stop the apphost if it's still running (Ctrl+C is safe even if already exited) + await auto.Ctrl().KeyAsync(Hex1bKey.C); + await auto.WaitForAnyPromptAsync(counter, timeout: TimeSpan.FromSeconds(30)); + + // Step 4: Verify aspire.config.json was created with the corrected path. + // The path should be "apphost.ts" (relative to workspace root), + // NOT "../apphost.ts" (the legacy .aspire/-relative path). + Assert.True(File.Exists(configPath), "aspire.config.json was not created by migration"); + var content = File.ReadAllText(configPath); + Assert.DoesNotContain("\"../apphost.ts\"", content); + Assert.Contains("\"apphost.ts\"", content); + + await auto.TypeAsync("exit"); + await auto.EnterAsync(); + + await pendingRun; + } +} diff --git a/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs b/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs index 4f2fcfee40a..ec3d9c4d6f6 100644 --- a/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs +++ b/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs @@ -336,4 +336,274 @@ public void Load_RoundTrips_WithProfiles() Assert.True(loaded.Profiles.ContainsKey("default")); Assert.Equal("https://localhost:5001", loaded.Profiles["default"].ApplicationUrl); } + + [Fact] + public void LoadOrCreate_MigratesLegacy_AdjustsRelativePathFromAspireDir() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + // Legacy .aspire/settings.json stores paths relative to the .aspire/ directory + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "../src/apphost.ts", + "language": "typescript/nodejs", + "sdkVersion": "13.2.0" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + // Path should be re-based from .aspire/-relative to root-relative + Assert.Equal("src/apphost.ts", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_AdjustsPathForApphostAtRoot() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + // Legacy path "../apphost.ts" means apphost is at the repo root + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "../apphost.ts", + "language": "typescript/nodejs" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + Assert.Equal("apphost.ts", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_RebasesSubdirectoryPath() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + // Legacy .aspire/settings.json stores appHostPath relative to .aspire/ directory. + // A path like "../MyApp.AppHost/MyApp.AppHost.csproj" points from .aspire/ up to + // the repo root, then into a subdirectory. After migration it should become + // "MyApp.AppHost/MyApp.AppHost.csproj" (relative to the repo root). + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "../MyApp.AppHost/MyApp.AppHost.csproj" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + Assert.Equal("MyApp.AppHost/MyApp.AppHost.csproj", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_SavesConfigFile() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "../src/apphost.ts", + "sdkVersion": "13.2.0" + } + """); + + AspireConfigFile.LoadOrCreate(root); + + // Verify aspire.config.json was created with correct content + var configPath = Path.Combine(root, AspireConfigFile.FileName); + Assert.True(File.Exists(configPath)); + + var saved = AspireConfigFile.Load(root); + Assert.NotNull(saved); + Assert.Equal("src/apphost.ts", saved.AppHost?.Path); + Assert.Equal("13.2.0", saved.SdkVersion); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_LeavesAbsolutePathUnchanged() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + var absolutePath = Path.Combine(root, "src", "apphost.ts").Replace(Path.DirectorySeparatorChar, '/'); + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, $$""" + { + "appHostPath": "{{absolutePath}}" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + // Absolute paths should not be modified + Assert.Equal(absolutePath, config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_NormalizesBackslashSeparators() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + // Simulate a settings file created on Windows with backslash separators. + // Even though we always store '/', handle '\' gracefully in case of manual edits. + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "..\\src\\apphost.ts", + "language": "typescript/nodejs" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + // Should be re-based and normalized to forward slashes + Assert.Equal("src/apphost.ts", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_OutputAlwaysUsesForwardSlashes() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "../deeply/nested/path/apphost.ts" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + // Verify output uses forward slashes regardless of platform + Assert.Equal("deeply/nested/path/apphost.ts", config.AppHost?.Path); + Assert.DoesNotContain("\\", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_SkipsEmptyPath() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "", + "language": "typescript/nodejs" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + // Empty path should not be transformed to "." + Assert.Equal("", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_SkipsNullPath() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "language": "typescript/nodejs" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + // No appHostPath means no migration needed; path stays null + Assert.Null(config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_DotSlashRelativePath() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + // "./MyApp.AppHost/apphost.ts" from .aspire/ dir resolves to .aspire/MyApp.AppHost/apphost.ts + // relative to root. While unusual, verifies dot-slash handling doesn't break. + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "./../MyApp.AppHost/apphost.ts" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + Assert.Equal("MyApp.AppHost/apphost.ts", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_BareRelativePath() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + // A bare relative path without ../ from .aspire/ stays under .aspire/ when resolved. + // In practice legacy paths always start with ../ but we verify the math is correct. + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "../MyApp.AppHost/MyApp.AppHost.csproj" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + Assert.Equal("MyApp.AppHost/MyApp.AppHost.csproj", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_LeavesUnixRootedPathUnchanged() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, """ + { + "appHostPath": "/path/apphost.ts" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + Assert.Equal("/path/apphost.ts", config.AppHost?.Path); + } + + [Fact] + public void LoadOrCreate_MigratesLegacy_LeavesWindowsRootedPathUnchanged() + { + Assert.SkipUnless(OperatingSystem.IsWindows(), "Windows-rooted paths are only recognized on Windows."); + + using var workspace = TemporaryWorkspace.Create(outputHelper); + var root = workspace.WorkspaceRoot.FullName; + + var settingsPath = Path.Combine(root, ".aspire", "settings.json"); + File.WriteAllText(settingsPath, $$""" + { + "appHostPath": "c:\\path\\apphost.ts" + } + """); + + var config = AspireConfigFile.LoadOrCreate(root); + + // On Windows, c:\ is rooted and should be left unchanged + Assert.Equal("c:\\path\\apphost.ts", config.AppHost?.Path); + } } From 930e921e86400d5cf73cabd839baadc68a7caecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Wed, 18 Mar 2026 21:07:54 -0700 Subject: [PATCH 12/49] Secure AppHost RPC with session token handshake (#15344) * Secure AppHost RPC with session token handshake Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix TypeScript RPC authentication request Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address AppHost RPC auth review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update SDKs with token checks * Move scoped registrations to correct location * Consolidate temporary AppHost sessions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix CI regressions after branch drift Sync the AppHost server project contract with current release/13.2 and make the RemoteHost authentication test tolerate the expected disconnect race after failed auth. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Aspire.Cli/Aspire.Cli.csproj | 1 + src/Aspire.Cli/Commands/Sdk/SdkDumpCommand.cs | 115 ++++----- .../Commands/Sdk/SdkGenerateCommand.cs | 73 ++---- src/Aspire.Cli/Projects/AppHostRpcClient.cs | 36 ++- .../Projects/AppHostServerSession.cs | 60 ++++- .../Projects/GuestAppHostProject.cs | 87 ++++--- src/Aspire.Cli/Projects/IAppHostRpcClient.cs | 2 +- .../Projects/IAppHostServerSession.cs | 5 + .../Scaffolding/ScaffoldingService.cs | 133 +++++----- .../AtsGoCodeGenerator.cs | 7 + .../Resources/transport.go | 15 ++ .../AtsJavaCodeGenerator.cs | 5 + .../Resources/Transport.java | 25 ++ .../AtsPythonCodeGenerator.cs | 4 + .../Resources/transport.py | 4 + .../AtsRustCodeGenerator.cs | 3 + .../Resources/transport.rs | 10 + .../Resources/transport.ts | 11 +- .../Aspire.Hosting.RemoteHost.csproj | 4 + .../CodeGeneration/CodeGenerationService.cs | 5 + .../JsonRpcAuthenticationState.cs | 70 +++++ .../JsonRpcServer.cs | 12 +- .../Language/LanguageService.cs | 6 + .../RemoteAppHostService.cs | 26 ++ .../RemoteHostServer.cs | 7 +- src/Shared/KnownConfigNames.cs | 1 + .../Projects/AppHostServerSessionTests.cs | 75 ++++++ .../Snapshots/AtsGeneratedAspire.verified.go | 7 + ...TwoPassScanningGeneratedAspire.verified.go | 7 + .../AtsJavaCodeGeneratorTests.cs | 1 + .../AtsGeneratedAspire.verified.java | 5 + ...oPassScanningGeneratedAspire.verified.java | 5 + .../Snapshots/AtsGeneratedAspire.verified.py | 4 + ...TwoPassScanningGeneratedAspire.verified.py | 4 + .../Snapshots/AtsGeneratedAspire.verified.rs | 3 + ...TwoPassScanningGeneratedAspire.verified.rs | 3 + .../tests/transport.test.ts | 80 +++++- .../Snapshots/transport.verified.ts | 13 +- .../JsonRpcAuthenticationTests.cs | 244 ++++++++++++++++++ 39 files changed, 909 insertions(+), 269 deletions(-) create mode 100644 src/Aspire.Hosting.RemoteHost/JsonRpcAuthenticationState.cs create mode 100644 tests/Aspire.Cli.Tests/Projects/AppHostServerSessionTests.cs create mode 100644 tests/Aspire.Hosting.RemoteHost.Tests/JsonRpcAuthenticationTests.cs diff --git a/src/Aspire.Cli/Aspire.Cli.csproj b/src/Aspire.Cli/Aspire.Cli.csproj index f1f659fdb07..adb5afa80a1 100644 --- a/src/Aspire.Cli/Aspire.Cli.csproj +++ b/src/Aspire.Cli/Aspire.Cli.csproj @@ -77,6 +77,7 @@ + diff --git a/src/Aspire.Cli/Commands/Sdk/SdkDumpCommand.cs b/src/Aspire.Cli/Commands/Sdk/SdkDumpCommand.cs index 938afbcbd61..9a58d9bed2f 100644 --- a/src/Aspire.Cli/Commands/Sdk/SdkDumpCommand.cs +++ b/src/Aspire.Cli/Commands/Sdk/SdkDumpCommand.cs @@ -164,84 +164,67 @@ private async Task DumpCapabilitiesAsync( return ExitCodeConstants.FailedToBuildArtifacts; } - // Start the server - var currentPid = Environment.ProcessId; - var (socketPath, serverProcess, _) = appHostServerProject.Run(currentPid, new Dictionary()); + await using var serverSession = AppHostServerSession.Start( + appHostServerProject, + environmentVariables: null, + debug: false, + _logger); - try - { - // Connect and get capabilities - await using var rpcClient = await AppHostRpcClient.ConnectAsync(socketPath, cancellationToken); + // Connect and get capabilities + var rpcClient = await serverSession.GetRpcClientAsync(cancellationToken); - _logger.LogDebug("Fetching capabilities via RPC"); - var capabilities = await rpcClient.GetCapabilitiesAsync(cancellationToken); + _logger.LogDebug("Fetching capabilities via RPC"); + var capabilities = await rpcClient.GetCapabilitiesAsync(cancellationToken); - // Output Info-level diagnostics to stderr via logger (shown with -d flag) - var infoDiagnostics = capabilities.Diagnostics.Where(d => d.Severity == "Info").ToList(); - foreach (var diag in infoDiagnostics) - { - var location = string.IsNullOrEmpty(diag.Location) ? "" : $" [{diag.Location}]"; - _logger.LogDebug("{Message}{Location}", diag.Message, location); - } + // Output Info-level diagnostics to stderr via logger (shown with -d flag) + var infoDiagnostics = capabilities.Diagnostics.Where(d => d.Severity == "Info").ToList(); + foreach (var diag in infoDiagnostics) + { + var location = string.IsNullOrEmpty(diag.Location) ? "" : $" [{diag.Location}]"; + _logger.LogDebug("{Message}{Location}", diag.Message, location); + } - // Remove Info diagnostics from output (they go to stderr only) - capabilities.Diagnostics.RemoveAll(d => d.Severity == "Info"); + // Remove Info diagnostics from output (they go to stderr only) + capabilities.Diagnostics.RemoveAll(d => d.Severity == "Info"); - // Stamp package versions for integrations that have them - var packageVersions = integrations - .Where(i => i.IsPackageReference) - .Select(i => new PackageInfo { Name = i.Name, Version = i.Version! }) - .ToList(); - if (packageVersions.Count > 0) - { - capabilities.Packages = packageVersions; - } + // Stamp package versions for integrations that have them + var packageVersions = integrations + .Where(i => i.IsPackageReference) + .Select(i => new PackageInfo { Name = i.Name, Version = i.Version! }) + .ToList(); + if (packageVersions.Count > 0) + { + capabilities.Packages = packageVersions; + } - // Format the output - var output = format switch - { - OutputFormat.Json => FormatJson(capabilities), - OutputFormat.Ci => FormatCi(capabilities), - _ => FormatPretty(capabilities) - }; + // Format the output + var output = format switch + { + OutputFormat.Json => FormatJson(capabilities), + OutputFormat.Ci => FormatCi(capabilities), + _ => FormatPretty(capabilities) + }; - // Write output - if (outputFile is not null) - { - var outputDir = outputFile.Directory; - if (outputDir is not null && !outputDir.Exists) - { - outputDir.Create(); - } - await File.WriteAllTextAsync(outputFile.FullName, output, cancellationToken); - InteractionService.DisplaySuccess($"Capabilities written to {outputFile.FullName}"); - } - else + // Write output + if (outputFile is not null) + { + var outputDir = outputFile.Directory; + if (outputDir is not null && !outputDir.Exists) { - // Output to stdout - Console.WriteLine(output); + outputDir.Create(); } - - // Return error code if there are errors in diagnostics - var hasErrors = capabilities.Diagnostics.Exists(d => d.Severity == "Error"); - return hasErrors ? ExitCodeConstants.InvalidCommand : ExitCodeConstants.Success; + await File.WriteAllTextAsync(outputFile.FullName, output, cancellationToken); + InteractionService.DisplaySuccess($"Capabilities written to {outputFile.FullName}"); } - finally + else { - // Stop the server - just try to kill, catch if already exited - try - { - serverProcess.Kill(entireProcessTree: true); - } - catch (InvalidOperationException) - { - // Process already exited - this is fine - } - catch (Exception ex) - { - _logger.LogDebug(ex, "Error killing AppHost server process"); - } + // Output to stdout + Console.WriteLine(output); } + + // Return error code if there are errors in diagnostics + var hasErrors = capabilities.Diagnostics.Exists(d => d.Severity == "Error"); + return hasErrors ? ExitCodeConstants.InvalidCommand : ExitCodeConstants.Success; } finally { diff --git a/src/Aspire.Cli/Commands/Sdk/SdkGenerateCommand.cs b/src/Aspire.Cli/Commands/Sdk/SdkGenerateCommand.cs index 5935fdc9561..ec0ab2021e2 100644 --- a/src/Aspire.Cli/Commands/Sdk/SdkGenerateCommand.cs +++ b/src/Aspire.Cli/Commands/Sdk/SdkGenerateCommand.cs @@ -158,60 +158,43 @@ private async Task GenerateSdkAsync( return ExitCodeConstants.FailedToBuildArtifacts; } - // Start the server - var currentPid = Environment.ProcessId; - var (socketPath, serverProcess, _) = appHostServerProject.Run(currentPid, new Dictionary()); + await using var serverSession = AppHostServerSession.Start( + appHostServerProject, + environmentVariables: null, + debug: false, + _logger); - try - { - // Connect and generate code - await using var rpcClient = await AppHostRpcClient.ConnectAsync(socketPath, cancellationToken); - - _logger.LogDebug("Generating {Language} SDK via RPC", languageInfo.CodeGenerator); - var generatedFiles = await rpcClient.GenerateCodeAsync(languageInfo.CodeGenerator, cancellationToken); - - // Write generated files - var outputDirFullPath = Path.GetFullPath(outputDir.FullName); - foreach (var (fileName, content) in generatedFiles) - { - var filePath = Path.GetFullPath(Path.Combine(outputDir.FullName, fileName)); + // Connect and generate code + var rpcClient = await serverSession.GetRpcClientAsync(cancellationToken); - // Validate path is within output directory (prevent path traversal) - if (!filePath.StartsWith(outputDirFullPath, StringComparison.OrdinalIgnoreCase)) - { - _logger.LogWarning("Skipping file with invalid path: {FileName}", fileName); - continue; - } + _logger.LogDebug("Generating {Language} SDK via RPC", languageInfo.CodeGenerator); + var generatedFiles = await rpcClient.GenerateCodeAsync(languageInfo.CodeGenerator, cancellationToken); - var fileDirectory = Path.GetDirectoryName(filePath); - if (!string.IsNullOrEmpty(fileDirectory)) - { - Directory.CreateDirectory(fileDirectory); - } - await File.WriteAllTextAsync(filePath, content, cancellationToken); - _logger.LogDebug("Wrote {FileName}", fileName); - } - - InteractionService.DisplaySuccess($"Generated {generatedFiles.Count} files in {outputDir.FullName}"); - - return ExitCodeConstants.Success; - } - finally + // Write generated files + var outputDirFullPath = Path.GetFullPath(outputDir.FullName); + foreach (var (fileName, content) in generatedFiles) { - // Stop the server - just try to kill, catch if already exited - try - { - serverProcess.Kill(entireProcessTree: true); - } - catch (InvalidOperationException) + var filePath = Path.GetFullPath(Path.Combine(outputDir.FullName, fileName)); + + // Validate path is within output directory (prevent path traversal) + if (!filePath.StartsWith(outputDirFullPath, StringComparison.OrdinalIgnoreCase)) { - // Process already exited - this is fine + _logger.LogWarning("Skipping file with invalid path: {FileName}", fileName); + continue; } - catch (Exception ex) + + var fileDirectory = Path.GetDirectoryName(filePath); + if (!string.IsNullOrEmpty(fileDirectory)) { - _logger.LogDebug(ex, "Error killing AppHost server process"); + Directory.CreateDirectory(fileDirectory); } + await File.WriteAllTextAsync(filePath, content, cancellationToken); + _logger.LogDebug("Wrote {FileName}", fileName); } + + InteractionService.DisplaySuccess($"Generated {generatedFiles.Count} files in {outputDir.FullName}"); + + return ExitCodeConstants.Success; } finally { diff --git a/src/Aspire.Cli/Projects/AppHostRpcClient.cs b/src/Aspire.Cli/Projects/AppHostRpcClient.cs index 74282884ce7..199bbc84371 100644 --- a/src/Aspire.Cli/Projects/AppHostRpcClient.cs +++ b/src/Aspire.Cli/Projects/AppHostRpcClient.cs @@ -24,18 +24,36 @@ private AppHostRpcClient(Stream stream, JsonRpc jsonRpc) } /// - /// Creates and connects an RPC client to the specified socket path. + /// Creates and connects an RPC client to the specified socket path and authenticates the session. /// - public static async Task ConnectAsync(string socketPath, CancellationToken cancellationToken) + public static async Task ConnectAsync(string socketPath, string authenticationToken, CancellationToken cancellationToken) { + ArgumentException.ThrowIfNullOrEmpty(authenticationToken); + var stream = await ConnectToServerAsync(socketPath, cancellationToken); + JsonRpc? jsonRpc = null; + + try + { + var formatter = BackchannelJsonSerializerContext.CreateRpcMessageFormatter(); + var handler = new HeaderDelimitedMessageHandler(stream, stream, formatter); + jsonRpc = new JsonRpc(handler); + jsonRpc.StartListening(); - var formatter = BackchannelJsonSerializerContext.CreateRpcMessageFormatter(); - var handler = new HeaderDelimitedMessageHandler(stream, stream, formatter); - var jsonRpc = new JsonRpc(handler); - jsonRpc.StartListening(); + var authenticated = await jsonRpc.InvokeWithCancellationAsync("authenticate", [authenticationToken], cancellationToken); + if (!authenticated) + { + throw new InvalidOperationException("Failed to authenticate to the AppHost server."); + } - return new AppHostRpcClient(stream, jsonRpc); + return new AppHostRpcClient(stream, jsonRpc); + } + catch + { + jsonRpc?.Dispose(); + await stream.DisposeAsync(); + throw; + } } // ═══════════════════════════════════════════════════════════════ @@ -160,8 +178,8 @@ private static async Task ConnectToServerAsync(string socketPath, Cancel internal sealed class AppHostRpcClientFactory : IAppHostRpcClientFactory { /// - public async Task ConnectAsync(string socketPath, CancellationToken cancellationToken) + public async Task ConnectAsync(string socketPath, string authenticationToken, CancellationToken cancellationToken) { - return await AppHostRpcClient.ConnectAsync(socketPath, cancellationToken); + return await AppHostRpcClient.ConnectAsync(socketPath, authenticationToken, cancellationToken); } } diff --git a/src/Aspire.Cli/Projects/AppHostServerSession.cs b/src/Aspire.Cli/Projects/AppHostServerSession.cs index e1376820cb0..b26e84e191b 100644 --- a/src/Aspire.Cli/Projects/AppHostServerSession.cs +++ b/src/Aspire.Cli/Projects/AppHostServerSession.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using Aspire.Cli.Configuration; using Aspire.Cli.Utils; +using Aspire.Hosting; using Microsoft.Extensions.Logging; namespace Aspire.Cli.Projects; @@ -13,6 +14,7 @@ namespace Aspire.Cli.Projects; /// internal sealed class AppHostServerSession : IAppHostServerSession { + private readonly string _authenticationToken; private readonly ILogger _logger; private readonly Process _serverProcess; private readonly OutputCollector _output; @@ -24,11 +26,13 @@ internal AppHostServerSession( Process serverProcess, OutputCollector output, string socketPath, + string authenticationToken, ILogger logger) { _serverProcess = serverProcess; _output = output; _socketPath = socketPath; + _authenticationToken = authenticationToken; _logger = logger; } @@ -41,12 +45,52 @@ internal AppHostServerSession( /// public OutputCollector Output => _output; + /// + /// Gets the authentication token for the server session. + /// + public string AuthenticationToken => _authenticationToken; + + /// + /// Starts an AppHost server process with an authentication token injected into the server environment. + /// + /// The server project to run. + /// The environment variables to pass to the server. + /// Whether to enable debug logging for the server. + /// The logger to use for lifecycle diagnostics. + /// The started AppHost server session. + internal static AppHostServerSession Start( + IAppHostServerProject appHostServerProject, + Dictionary? environmentVariables, + bool debug, + ILogger logger) + { + var currentPid = Environment.ProcessId; + var serverEnvironmentVariables = environmentVariables is null + ? new Dictionary() + : new Dictionary(environmentVariables); + + var authenticationToken = TokenGenerator.GenerateToken(); + serverEnvironmentVariables[KnownConfigNames.RemoteAppHostToken] = authenticationToken; + + var (socketPath, serverProcess, serverOutput) = appHostServerProject.Run( + currentPid, + serverEnvironmentVariables, + debug: debug); + + return new AppHostServerSession( + serverProcess, + serverOutput, + socketPath, + authenticationToken, + logger); + } + /// public async Task GetRpcClientAsync(CancellationToken cancellationToken) { ObjectDisposedException.ThrowIf(_disposed, nameof(AppHostServerSession)); - return _rpcClient ??= await AppHostRpcClient.ConnectAsync(_socketPath, cancellationToken); + return _rpcClient ??= await AppHostRpcClient.ConnectAsync(_socketPath, _authenticationToken, cancellationToken); } /// @@ -119,18 +163,10 @@ public async Task CreateAsync( ChannelName: prepareResult.ChannelName); } - // Start the server process - var currentPid = Environment.ProcessId; - var (socketPath, serverProcess, serverOutput) = appHostServerProject.Run( - currentPid, + var session = AppHostServerSession.Start( + appHostServerProject, launchSettingsEnvVars, - debug: debug); - - // Create the session - var session = new AppHostServerSession( - serverProcess, - serverOutput, - socketPath, + debug, _logger); return new AppHostServerSessionResult( diff --git a/src/Aspire.Cli/Projects/GuestAppHostProject.cs b/src/Aspire.Cli/Projects/GuestAppHostProject.cs index 8cbe971908b..e856ebce8ff 100644 --- a/src/Aspire.Cli/Projects/GuestAppHostProject.cs +++ b/src/Aspire.Cli/Projects/GuestAppHostProject.cs @@ -258,41 +258,26 @@ internal async Task BuildAndGenerateSdkAsync(DirectoryInfo directory, Canc } // Step 2: Start the AppHost server temporarily for code generation - var currentPid = Environment.ProcessId; - var (socketPath, serverProcess, _) = appHostServerProject.Run(currentPid); - - try - { - // Step 3: Connect to server - await using var rpcClient = await AppHostRpcClient.ConnectAsync(socketPath, cancellationToken); - - // Step 4: Install dependencies using GuestRuntime (best effort - don't block code generation) - await InstallDependenciesAsync(directory, rpcClient, cancellationToken); - - // Step 5: Generate SDK code via RPC - await GenerateCodeViaRpcAsync( - directory.FullName, - rpcClient, - integrations, - cancellationToken); - - return true; - } - finally - { - // Step 6: Stop the server (we were just generating code) - if (!serverProcess.HasExited) - { - try - { - serverProcess.Kill(entireProcessTree: true); - } - catch (Exception ex) - { - _logger.LogDebug(ex, "Error killing AppHost server process after code generation"); - } - } - } + await using var serverSession = AppHostServerSession.Start( + appHostServerProject, + environmentVariables: null, + debug: false, + _logger); + + // Step 3: Connect to server + var rpcClient = await serverSession.GetRpcClientAsync(cancellationToken); + + // Step 4: Install dependencies using GuestRuntime (best effort - don't block code generation) + await InstallDependenciesAsync(directory, rpcClient, cancellationToken); + + // Step 5: Generate SDK code via RPC + await GenerateCodeViaRpcAsync( + directory.FullName, + rpcClient, + integrations, + cancellationToken); + + return true; } Task IGuestAppHostSdkGenerator.BuildAndGenerateSdkAsync(DirectoryInfo directory, CancellationToken cancellationToken) @@ -423,8 +408,15 @@ public async Task RunAsync(AppHostProjectContext context, CancellationToken var enableHotReload = _features.IsFeatureEnabled(KnownFeatures.DefaultWatchEnabled, defaultValue: false); // Start the AppHost server process - var currentPid = Environment.ProcessId; - var (socketPath, appHostServerProcess, appHostServerOutputCollector) = appHostServerProject.Run(currentPid, launchSettingsEnvVars, debug: context.Debug); + await using var serverSession = AppHostServerSession.Start( + appHostServerProject, + launchSettingsEnvVars, + context.Debug, + _logger); + var socketPath = serverSession.SocketPath; + var appHostServerProcess = serverSession.ServerProcess; + var appHostServerOutputCollector = serverSession.Output; + var authenticationToken = serverSession.AuthenticationToken; // The backchannel completion source is the contract with RunCommand // We signal this when the backchannel is ready, RunCommand uses it for UX @@ -444,7 +436,7 @@ public async Task RunAsync(AppHostProjectContext context, CancellationToken } // Step 5: Connect to server for RPC calls - await using var rpcClient = await AppHostRpcClient.ConnectAsync(socketPath, cancellationToken); + var rpcClient = await serverSession.GetRpcClientAsync(cancellationToken); // Step 6: Install dependencies (using GuestRuntime) // The GuestRuntime will skip if the RuntimeSpec doesn't have InstallDependencies configured @@ -486,7 +478,8 @@ await GenerateCodeViaRpcAsync( { ["REMOTE_APP_HOST_SOCKET_PATH"] = socketPath, ["ASPIRE_PROJECT_DIRECTORY"] = directory.FullName, - ["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName + ["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName, + [KnownConfigNames.RemoteAppHostToken] = authenticationToken }; // Check if the extension should launch the guest app host (for VS Code debugging). @@ -788,8 +781,15 @@ public async Task PublishAsync(PublishContext context, CancellationToken ca launchSettingsEnvVars[KnownConfigNames.AspireUserSecretsId] = UserSecretsPathHelper.ComputeSyntheticUserSecretsId(appHostFile.FullName); // Step 2: Start the AppHost server process(it opens the backchannel for progress reporting) - var currentPid = Environment.ProcessId; - var (jsonRpcSocketPath, appHostServerProcess, appHostServerOutputCollector) = appHostServerProject.Run(currentPid, launchSettingsEnvVars, debug: context.Debug); + await using var serverSession = AppHostServerSession.Start( + appHostServerProject, + launchSettingsEnvVars, + context.Debug, + _logger); + var jsonRpcSocketPath = serverSession.SocketPath; + var appHostServerProcess = serverSession.ServerProcess; + var appHostServerOutputCollector = serverSession.Output; + var authenticationToken = serverSession.AuthenticationToken; // Start connecting to the backchannel if (context.BackchannelCompletionSource is not null) @@ -808,7 +808,7 @@ public async Task PublishAsync(PublishContext context, CancellationToken ca } // Step 3: Connect to server for RPC calls - await using var rpcClient = await AppHostRpcClient.ConnectAsync(jsonRpcSocketPath, cancellationToken); + var rpcClient = await serverSession.GetRpcClientAsync(cancellationToken); // Step 4: Install dependencies if needed (using GuestRuntime) // The GuestRuntime will skip if the RuntimeSpec doesn't have InstallDependencies configured @@ -848,7 +848,8 @@ await GenerateCodeViaRpcAsync( { ["REMOTE_APP_HOST_SOCKET_PATH"] = jsonRpcSocketPath, ["ASPIRE_PROJECT_DIRECTORY"] = directory.FullName, - ["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName + ["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName, + [KnownConfigNames.RemoteAppHostToken] = authenticationToken }; // Step 6: Execute the guest apphost for publishing diff --git a/src/Aspire.Cli/Projects/IAppHostRpcClient.cs b/src/Aspire.Cli/Projects/IAppHostRpcClient.cs index 371cb734413..445faaa879d 100644 --- a/src/Aspire.Cli/Projects/IAppHostRpcClient.cs +++ b/src/Aspire.Cli/Projects/IAppHostRpcClient.cs @@ -69,5 +69,5 @@ internal interface IAppHostRpcClientFactory /// Creates and connects an RPC client to the specified socket path. /// Handles platform-specific connection (Unix sockets vs named pipes). /// - Task ConnectAsync(string socketPath, CancellationToken cancellationToken); + Task ConnectAsync(string socketPath, string authenticationToken, CancellationToken cancellationToken); } diff --git a/src/Aspire.Cli/Projects/IAppHostServerSession.cs b/src/Aspire.Cli/Projects/IAppHostServerSession.cs index 8668a92796c..8fce43a2ec0 100644 --- a/src/Aspire.Cli/Projects/IAppHostServerSession.cs +++ b/src/Aspire.Cli/Projects/IAppHostServerSession.cs @@ -29,6 +29,11 @@ internal interface IAppHostServerSession : IAsyncDisposable /// OutputCollector Output { get; } + /// + /// Gets the authentication token for the server session. + /// + string AuthenticationToken { get; } + /// /// Gets an RPC client connected to this session. /// diff --git a/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs b/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs index 566fec78312..9b8dffb1fd1 100644 --- a/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs +++ b/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs @@ -79,95 +79,80 @@ private async Task ScaffoldGuestLanguageAsync(ScaffoldContext context, Can } // Step 2: Start the server temporarily for scaffolding and code generation - var currentPid = Environment.ProcessId; - var (socketPath, serverProcess, _) = appHostServerProject.Run(currentPid, new Dictionary()); - - try + await using var serverSession = AppHostServerSession.Start( + appHostServerProject, + environmentVariables: null, + debug: false, + _logger); + + // Step 3: Connect to server and get scaffold templates via RPC + var rpcClient = await serverSession.GetRpcClientAsync(cancellationToken); + + var scaffoldFiles = await rpcClient.ScaffoldAppHostAsync( + language.LanguageId, + directory.FullName, + context.ProjectName, + cancellationToken); + + // Step 4: Write scaffold files to disk + foreach (var (fileName, content) in scaffoldFiles) { - // Step 3: Connect to server and get scaffold templates via RPC - await using var rpcClient = await AppHostRpcClient.ConnectAsync(socketPath, cancellationToken); - - var scaffoldFiles = await rpcClient.ScaffoldAppHostAsync( - language.LanguageId, - directory.FullName, - context.ProjectName, - cancellationToken); - - // Step 4: Write scaffold files to disk - foreach (var (fileName, content) in scaffoldFiles) + var filePath = Path.Combine(directory.FullName, fileName); + var fileDirectory = Path.GetDirectoryName(filePath); + if (!string.IsNullOrEmpty(fileDirectory)) { - var filePath = Path.Combine(directory.FullName, fileName); - var fileDirectory = Path.GetDirectoryName(filePath); - if (!string.IsNullOrEmpty(fileDirectory)) - { - Directory.CreateDirectory(fileDirectory); - } - await File.WriteAllTextAsync(filePath, content, cancellationToken); + Directory.CreateDirectory(fileDirectory); } + await File.WriteAllTextAsync(filePath, content, cancellationToken); + } - _logger.LogDebug("Wrote {Count} scaffold files", scaffoldFiles.Count); + _logger.LogDebug("Wrote {Count} scaffold files", scaffoldFiles.Count); - // Step 5: Install dependencies using GuestRuntime - var installResult = await _interactionService.ShowStatusAsync( - $"Installing {language.DisplayName} dependencies...", - () => InstallDependenciesAsync(directory, language, rpcClient, cancellationToken), - emoji: KnownEmojis.Package); - if (installResult != 0) - { - return false; - } + // Step 5: Install dependencies using GuestRuntime + var installResult = await _interactionService.ShowStatusAsync( + $"Installing {language.DisplayName} dependencies...", + () => InstallDependenciesAsync(directory, language, rpcClient, cancellationToken), + emoji: KnownEmojis.Package); + if (installResult != 0) + { + return false; + } - // Step 6: Generate SDK code via RPC - await GenerateCodeViaRpcAsync( - directory.FullName, - rpcClient, - language, - cancellationToken); + // Step 6: Generate SDK code via RPC + await GenerateCodeViaRpcAsync( + directory.FullName, + rpcClient, + language, + cancellationToken); - // Save channel and language to aspire.config.json (new format) - // Read profiles from apphost.run.json (created by codegen) and merge into aspire.config.json - var appHostRunPath = Path.Combine(directory.FullName, "apphost.run.json"); - var profiles = AspireConfigFile.ReadApphostRunProfiles(appHostRunPath, _logger); + // Save channel and language to aspire.config.json (new format) + // Read profiles from apphost.run.json (created by codegen) and merge into aspire.config.json + var appHostRunPath = Path.Combine(directory.FullName, "apphost.run.json"); + var profiles = AspireConfigFile.ReadApphostRunProfiles(appHostRunPath, _logger); - if (profiles is not null && File.Exists(appHostRunPath)) + if (profiles is not null && File.Exists(appHostRunPath)) + { + try { - try - { - // Delete apphost.run.json since profiles are now in aspire.config.json - File.Delete(appHostRunPath); - } - catch (Exception ex) - { - _logger.LogDebug(ex, "Failed to delete apphost.run.json after reading profiles"); - } + // Delete apphost.run.json since profiles are now in aspire.config.json + File.Delete(appHostRunPath); } - - config.Profiles = profiles; - if (prepareResult.ChannelName is not null) + catch (Exception ex) { - config.Channel = prepareResult.ChannelName; + _logger.LogDebug(ex, "Failed to delete apphost.run.json after reading profiles"); } - config.AppHost ??= new AspireConfigAppHost(); - config.AppHost.Path ??= language.AppHostFileName; - config.AppHost.Language = language.LanguageId; - config.Save(directory.FullName); - return true; } - finally + + config.Profiles = profiles; + if (prepareResult.ChannelName is not null) { - // Step 7: Stop the server - if (!serverProcess.HasExited) - { - try - { - serverProcess.Kill(entireProcessTree: true); - } - catch (Exception ex) - { - _logger.LogDebug(ex, "Error killing AppHost server process after scaffolding"); - } - } + config.Channel = prepareResult.ChannelName; } + config.AppHost ??= new AspireConfigAppHost(); + config.AppHost.Path ??= language.AppHostFileName; + config.AppHost.Language = language.LanguageId; + config.Save(directory.FullName); + return true; } private async Task InstallDependenciesAsync( diff --git a/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs index 00e2fd1e658..780aee66108 100644 --- a/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs @@ -492,6 +492,13 @@ private void GenerateConnectionHelpers() WriteLine("\tif err := client.Connect(); err != nil {"); WriteLine("\t\treturn nil, err"); WriteLine("\t}"); + WriteLine("\tauthToken := os.Getenv(\"ASPIRE_REMOTE_APPHOST_TOKEN\")"); + WriteLine("\tif authToken == \"\" {"); + WriteLine("\t\treturn nil, fmt.Errorf(\"ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`\")"); + WriteLine("\t}"); + WriteLine("\tif err := client.Authenticate(authToken); err != nil {"); + WriteLine("\t\treturn nil, err"); + WriteLine("\t}"); WriteLine("\tclient.OnDisconnect(func() { os.Exit(1) })"); WriteLine("\treturn client, nil"); WriteLine("}"); diff --git a/src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go b/src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go index 79e8c8c5d27..9bceaa57181 100644 --- a/src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go +++ b/src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go @@ -268,6 +268,21 @@ func (c *AspireClient) InvokeCapability(capabilityID string, args map[string]any return WrapIfHandle(result, c), nil } +// Authenticate authenticates the client session with the AppHost server. +func (c *AspireClient) Authenticate(token string) error { + result, err := c.sendRequest("authenticate", []any{token}) + if err != nil { + return err + } + + authenticated, _ := result.(bool) + if !authenticated { + return errors.New("failed to authenticate to the AppHost server") + } + + return nil +} + // CancelToken cancels a cancellation token on the server. func (c *AspireClient) CancelToken(tokenID string) bool { result, err := c.sendRequest("cancelToken", []any{tokenID}) diff --git a/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs index a117af08ff5..5663376668a 100644 --- a/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs @@ -469,6 +469,11 @@ private void GenerateConnectionHelpers() WriteLine(" }"); WriteLine(" AspireClient client = new AspireClient(socketPath);"); WriteLine(" client.connect();"); + WriteLine(" String authToken = System.getenv(\"ASPIRE_REMOTE_APPHOST_TOKEN\");"); + WriteLine(" if (authToken == null || authToken.isEmpty()) {"); + WriteLine(" throw new RuntimeException(\"ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`.\");"); + WriteLine(" }"); + WriteLine(" client.authenticate(authToken);"); WriteLine(" client.onDisconnect(() -> System.exit(1));"); WriteLine(" return client;"); WriteLine(" }"); diff --git a/src/Aspire.Hosting.CodeGeneration.Java/Resources/Transport.java b/src/Aspire.Hosting.CodeGeneration.Java/Resources/Transport.java index cef9f1cefd9..8848ded3137 100644 --- a/src/Aspire.Hosting.CodeGeneration.Java/Resources/Transport.java +++ b/src/Aspire.Hosting.CodeGeneration.Java/Resources/Transport.java @@ -181,6 +181,31 @@ public Object invokeCapability(String capabilityId, Map args) { } } + public void authenticate(String token) { + int id = requestId.incrementAndGet(); + + List params = List.of(token); + + Map request = new HashMap<>(); + request.put("jsonrpc", "2.0"); + request.put("id", id); + request.put("method", "authenticate"); + request.put("params", params); + + debug("Sending request authenticate with id=" + id); + + try { + sendMessage(request); + Object result = readResponse(id); + if (!(result instanceof Boolean authenticated) || !authenticated) { + throw new RuntimeException("Failed to authenticate to the AppHost server."); + } + } catch (IOException e) { + handleDisconnect(); + throw new RuntimeException("Failed to authenticate: " + e.getMessage(), e); + } + } + private void sendMessage(Map message) throws IOException { String json = toJson(message); byte[] content = json.getBytes(StandardCharsets.UTF_8); diff --git a/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs index fd4db795ff2..d2b8d94b043 100644 --- a/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs @@ -384,6 +384,10 @@ private void GenerateConnectionHelpers() WriteLine(" raise RuntimeError(\"REMOTE_APP_HOST_SOCKET_PATH environment variable not set. Run this application using `aspire run`.\")"); WriteLine(" client = AspireClient(socket_path)"); WriteLine(" client.connect()"); + WriteLine(" auth_token = os.environ.get(\"ASPIRE_REMOTE_APPHOST_TOKEN\")"); + WriteLine(" if not auth_token:"); + WriteLine(" raise RuntimeError(\"ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`.\")"); + WriteLine(" client.authenticate(auth_token)"); WriteLine(" client.on_disconnect(lambda: sys.exit(1))"); WriteLine(" return client"); WriteLine(); diff --git a/src/Aspire.Hosting.CodeGeneration.Python/Resources/transport.py b/src/Aspire.Hosting.CodeGeneration.Python/Resources/transport.py index a06ca8d6e23..de4b2ddef2a 100644 --- a/src/Aspire.Hosting.CodeGeneration.Python/Resources/transport.py +++ b/src/Aspire.Hosting.CodeGeneration.Python/Resources/transport.py @@ -154,6 +154,10 @@ def invoke_capability(self, capability_id: str, args: Optional[Dict[str, Any]] = raise CapabilityError(result["$error"]) return wrap_if_handle(result, self) + def authenticate(self, token: str) -> None: + if not bool(self._send_request("authenticate", [token])): + raise RuntimeError("Failed to authenticate to the AppHost server.") + def cancel_token(self, token_id: str) -> bool: return bool(self._send_request("cancelToken", [token_id])) diff --git a/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs index 8d951576272..ccefa5c38c1 100644 --- a/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs @@ -573,6 +573,9 @@ private void GenerateConnectionHelpers() WriteLine(" .map_err(|_| \"REMOTE_APP_HOST_SOCKET_PATH environment variable not set. Run this application using `aspire run`\")?;"); WriteLine(" let client = Arc::new(AspireClient::new(&socket_path));"); WriteLine(" client.connect()?;"); + WriteLine(" let auth_token = std::env::var(\"ASPIRE_REMOTE_APPHOST_TOKEN\")"); + WriteLine(" .map_err(|_| \"ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`\")?;"); + WriteLine(" client.authenticate(&auth_token)?;"); WriteLine(" Ok(client)"); WriteLine("}"); WriteLine(); diff --git a/src/Aspire.Hosting.CodeGeneration.Rust/Resources/transport.rs b/src/Aspire.Hosting.CodeGeneration.Rust/Resources/transport.rs index 14a28068766..48acf677c35 100644 --- a/src/Aspire.Hosting.CodeGeneration.Rust/Resources/transport.rs +++ b/src/Aspire.Hosting.CodeGeneration.Rust/Resources/transport.rs @@ -307,6 +307,16 @@ impl AspireClient { Ok(wrap_if_handle(result, None)) } + /// Authenticates the client session with the AppHost server. + pub fn authenticate(&self, token: &str) -> Result<(), Box> { + let result = self.send_request("authenticate", json!([token]))?; + if result.as_bool().unwrap_or(false) { + return Ok(()); + } + + Err("Failed to authenticate to the AppHost server.".into()) + } + /// Cancels a cancellation token on the server. pub fn cancel_token(&self, token_id: &str) -> Result> { let result = self.send_request("cancelToken", json!([token_id]))?; diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts index 904e57142f9..6d29cf289d9 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts @@ -830,7 +830,7 @@ export class AspireClient { failConnect(new Error('Connection closed before JSON-RPC was established')); }; - const onConnect = () => { + const onConnect = async () => { if (settled) { return; } @@ -867,7 +867,16 @@ export class AspireClient { 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; diff --git a/src/Aspire.Hosting.RemoteHost/Aspire.Hosting.RemoteHost.csproj b/src/Aspire.Hosting.RemoteHost/Aspire.Hosting.RemoteHost.csproj index e87b27d2ab4..e55b097a6ef 100644 --- a/src/Aspire.Hosting.RemoteHost/Aspire.Hosting.RemoteHost.csproj +++ b/src/Aspire.Hosting.RemoteHost/Aspire.Hosting.RemoteHost.csproj @@ -21,6 +21,10 @@ + + + + diff --git a/src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs b/src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs index ea5d6005545..02580681da6 100644 --- a/src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs +++ b/src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs @@ -12,15 +12,18 @@ namespace Aspire.Hosting.RemoteHost.CodeGeneration; /// internal sealed class CodeGenerationService { + private readonly JsonRpcAuthenticationState _authenticationState; private readonly AtsContextFactory _atsContextFactory; private readonly CodeGeneratorResolver _resolver; private readonly ILogger _logger; public CodeGenerationService( + JsonRpcAuthenticationState authenticationState, AtsContextFactory atsContextFactory, CodeGeneratorResolver resolver, ILogger logger) { + _authenticationState = authenticationState; _atsContextFactory = atsContextFactory; _resolver = resolver; _logger = logger; @@ -33,6 +36,7 @@ public CodeGenerationService( [JsonRpcMethod("getCapabilities")] public CapabilitiesResponse GetCapabilities() { + _authenticationState.ThrowIfNotAuthenticated(); _logger.LogDebug(">> getCapabilities()"); var sw = System.Diagnostics.Stopwatch.StartNew(); @@ -150,6 +154,7 @@ public CapabilitiesResponse GetCapabilities() [JsonRpcMethod("generateCode")] public Dictionary GenerateCode(string language) { + _authenticationState.ThrowIfNotAuthenticated(); _logger.LogDebug(">> generateCode({Language})", language); var sw = System.Diagnostics.Stopwatch.StartNew(); diff --git a/src/Aspire.Hosting.RemoteHost/JsonRpcAuthenticationState.cs b/src/Aspire.Hosting.RemoteHost/JsonRpcAuthenticationState.cs new file mode 100644 index 00000000000..dff2603cb75 --- /dev/null +++ b/src/Aspire.Hosting.RemoteHost/JsonRpcAuthenticationState.cs @@ -0,0 +1,70 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Security.Cryptography; +using System.Text; +using Microsoft.Extensions.Configuration; + +namespace Aspire.Hosting.RemoteHost; + +internal sealed class JsonRpcAuthenticationState +{ + private readonly byte[]? _expectedTokenBytes; + + public JsonRpcAuthenticationState(IConfiguration configuration) + { + if (configuration[KnownConfigNames.RemoteAppHostToken] is { Length: > 0 } token) + { + _expectedTokenBytes = Encoding.UTF8.GetBytes(token); + } + + IsAuthenticated = _expectedTokenBytes is null; + } + + public bool IsAuthenticated { get; private set; } + + public bool Authenticate(string token) + { + if (IsAuthenticated) + { + return true; + } + + if (_expectedTokenBytes is null) + { + IsAuthenticated = true; + return true; + } + + if (string.IsNullOrEmpty(token)) + { + return false; + } + + var providedTokenBytes = Encoding.UTF8.GetBytes(token); + + try + { + var isMatch = CryptographicOperations.FixedTimeEquals(providedTokenBytes, _expectedTokenBytes); + + if (isMatch) + { + IsAuthenticated = true; + } + + return isMatch; + } + finally + { + CryptographicOperations.ZeroMemory(providedTokenBytes); + } + } + + public void ThrowIfNotAuthenticated() + { + if (!IsAuthenticated) + { + throw new InvalidOperationException("Client must authenticate before invoking AppHost RPC methods."); + } + } +} diff --git a/src/Aspire.Hosting.RemoteHost/JsonRpcServer.cs b/src/Aspire.Hosting.RemoteHost/JsonRpcServer.cs index 5128be80e0e..55585cae34f 100644 --- a/src/Aspire.Hosting.RemoteHost/JsonRpcServer.cs +++ b/src/Aspire.Hosting.RemoteHost/JsonRpcServer.cs @@ -20,8 +20,6 @@ internal sealed class JsonRpcServer : BackgroundService { private readonly string _socketPath; private readonly IServiceScopeFactory _scopeFactory; - private readonly CodeGenerationService _codeGenerationService; - private readonly LanguageService _languageService; private readonly ILogger _logger; private Socket? _listenSocket; private bool _disposed; @@ -30,13 +28,9 @@ internal sealed class JsonRpcServer : BackgroundService public JsonRpcServer( IConfiguration configuration, IServiceScopeFactory scopeFactory, - CodeGenerationService codeGenerationService, - LanguageService languageService, ILogger logger) { _scopeFactory = scopeFactory; - _codeGenerationService = codeGenerationService; - _languageService = languageService; _logger = logger; var socketPath = configuration["REMOTE_APP_HOST_SOCKET_PATH"]; @@ -194,6 +188,8 @@ private async Task HandleClientStreamAsync(Stream clientStream, bool ownsStream, // Resolve the scoped RemoteAppHostService var clientService = scope.ServiceProvider.GetRequiredService(); + var codeGenerationService = scope.ServiceProvider.GetRequiredService(); + var languageService = scope.ServiceProvider.GetRequiredService(); try { @@ -203,10 +199,10 @@ private async Task HandleClientStreamAsync(Stream clientStream, bool ownsStream, using var jsonRpc = new JsonRpc(handler, clientService); // Add the shared CodeGenerationService as an additional target for generateCode method - jsonRpc.AddLocalRpcTarget(_codeGenerationService); + jsonRpc.AddLocalRpcTarget(codeGenerationService); // Add the shared LanguageService as an additional target for language support methods - jsonRpc.AddLocalRpcTarget(_languageService); + jsonRpc.AddLocalRpcTarget(languageService); jsonRpc.StartListening(); diff --git a/src/Aspire.Hosting.RemoteHost/Language/LanguageService.cs b/src/Aspire.Hosting.RemoteHost/Language/LanguageService.cs index 7a14aa97887..738611bdb57 100644 --- a/src/Aspire.Hosting.RemoteHost/Language/LanguageService.cs +++ b/src/Aspire.Hosting.RemoteHost/Language/LanguageService.cs @@ -13,13 +13,16 @@ namespace Aspire.Hosting.RemoteHost.Language; /// internal sealed class LanguageService { + private readonly JsonRpcAuthenticationState _authenticationState; private readonly LanguageSupportResolver _resolver; private readonly ILogger _logger; public LanguageService( + JsonRpcAuthenticationState authenticationState, LanguageSupportResolver resolver, ILogger logger) { + _authenticationState = authenticationState; _resolver = resolver; _logger = logger; } @@ -34,6 +37,7 @@ public LanguageService( [JsonRpcMethod("scaffoldAppHost")] public Dictionary ScaffoldAppHost(string language, string targetPath, string? projectName = null) { + _authenticationState.ThrowIfNotAuthenticated(); _logger.LogDebug(">> scaffoldAppHost({Language}, {TargetPath}, {ProjectName})", language, targetPath, projectName); var sw = Stopwatch.StartNew(); @@ -71,6 +75,7 @@ public Dictionary ScaffoldAppHost(string language, string target [JsonRpcMethod("detectAppHostType")] public DetectionResult DetectAppHostType(string directoryPath) { + _authenticationState.ThrowIfNotAuthenticated(); _logger.LogDebug(">> detectAppHostType({DirectoryPath})", directoryPath); var sw = System.Diagnostics.Stopwatch.StartNew(); @@ -104,6 +109,7 @@ public DetectionResult DetectAppHostType(string directoryPath) [JsonRpcMethod("getRuntimeSpec")] public RuntimeSpec GetRuntimeSpec(string language) { + _authenticationState.ThrowIfNotAuthenticated(); _logger.LogDebug(">> getRuntimeSpec({Language})", language); var sw = System.Diagnostics.Stopwatch.StartNew(); diff --git a/src/Aspire.Hosting.RemoteHost/RemoteAppHostService.cs b/src/Aspire.Hosting.RemoteHost/RemoteAppHostService.cs index f67cd6d0fb9..d2f9aa48764 100644 --- a/src/Aspire.Hosting.RemoteHost/RemoteAppHostService.cs +++ b/src/Aspire.Hosting.RemoteHost/RemoteAppHostService.cs @@ -10,19 +10,23 @@ namespace Aspire.Hosting.RemoteHost; internal sealed class RemoteAppHostService { + private readonly JsonRpcAuthenticationState _authenticationState; private readonly JsonRpcCallbackInvoker _callbackInvoker; private readonly CancellationTokenRegistry _cancellationTokenRegistry; private readonly ILogger _logger; + private JsonRpc? _clientRpc; // ATS (Aspire Type System) components private readonly CapabilityDispatcher _capabilityDispatcher; public RemoteAppHostService( + JsonRpcAuthenticationState authenticationState, JsonRpcCallbackInvoker callbackInvoker, CancellationTokenRegistry cancellationTokenRegistry, CapabilityDispatcher capabilityDispatcher, ILogger logger) { + _authenticationState = authenticationState; _callbackInvoker = callbackInvoker; _cancellationTokenRegistry = cancellationTokenRegistry; _capabilityDispatcher = capabilityDispatcher; @@ -34,9 +38,29 @@ public RemoteAppHostService( /// public void SetClientConnection(JsonRpc clientRpc) { + _clientRpc = clientRpc; _callbackInvoker.SetConnection(clientRpc); } + /// + /// Verifies the authentication token supplied by the client. + /// Returns true on success; closes the connection and returns false on failure + /// so that an unauthenticated client cannot keep retrying without limit. + /// + [JsonRpcMethod("authenticate")] + public bool Authenticate(string token) + { + var authenticated = _authenticationState.Authenticate(token); + if (!authenticated) + { + _logger.LogWarning("Rejected unauthenticated AppHost RPC client."); + // Close the connection to prevent unlimited retry attempts. + _ = Task.Run(() => _clientRpc?.Dispose()); + } + + return authenticated; + } + [JsonRpcMethod("ping")] #pragma warning disable CA1822 // Mark members as static - JSON-RPC methods must be instance methods public string Ping() @@ -54,6 +78,7 @@ public string Ping() [JsonRpcMethod("cancelToken")] public bool CancelToken(string tokenId) { + _authenticationState.ThrowIfNotAuthenticated(); _logger.LogDebug("cancelToken({TokenId})", tokenId); return _cancellationTokenRegistry.Cancel(tokenId); } @@ -69,6 +94,7 @@ public bool CancelToken(string tokenId) [JsonRpcMethod("invokeCapability")] public async Task InvokeCapabilityAsync(string capabilityId, JsonObject? args) { + _authenticationState.ThrowIfNotAuthenticated(); _logger.LogDebug(">> invokeCapability({CapabilityId}) args: {Args}", capabilityId, args?.ToJsonString() ?? "null"); var sw = System.Diagnostics.Stopwatch.StartNew(); try diff --git a/src/Aspire.Hosting.RemoteHost/RemoteHostServer.cs b/src/Aspire.Hosting.RemoteHost/RemoteHostServer.cs index 61aacab0f6d..5de5abe83ce 100644 --- a/src/Aspire.Hosting.RemoteHost/RemoteHostServer.cs +++ b/src/Aspire.Hosting.RemoteHost/RemoteHostServer.cs @@ -46,11 +46,12 @@ private static void ConfigureServices(IServiceCollection services) services.AddSingleton(); services.AddSingleton(sp => sp.GetRequiredService().GetContext()); services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); - // Register scoped services for per-client state + // Scoped services + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/src/Shared/KnownConfigNames.cs b/src/Shared/KnownConfigNames.cs index 57d3f2dbe54..5ef33693d5d 100644 --- a/src/Shared/KnownConfigNames.cs +++ b/src/Shared/KnownConfigNames.cs @@ -30,6 +30,7 @@ internal static class KnownConfigNames public const string WaitForDebugger = "ASPIRE_WAIT_FOR_DEBUGGER"; public const string WaitForDebuggerTimeout = "ASPIRE_DEBUGGER_TIMEOUT"; public const string UnixSocketPath = "ASPIRE_BACKCHANNEL_PATH"; + public const string RemoteAppHostToken = "ASPIRE_REMOTE_APPHOST_TOKEN"; public const string CliProcessId = "ASPIRE_CLI_PID"; public const string CliProcessStarted = "ASPIRE_CLI_STARTED"; public const string ForceRichConsole = "ASPIRE_FORCE_RICH_CONSOLE"; diff --git a/tests/Aspire.Cli.Tests/Projects/AppHostServerSessionTests.cs b/tests/Aspire.Cli.Tests/Projects/AppHostServerSessionTests.cs new file mode 100644 index 00000000000..de3e08ef937 --- /dev/null +++ b/tests/Aspire.Cli.Tests/Projects/AppHostServerSessionTests.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using Aspire.Cli.Configuration; +using Aspire.Cli.Projects; +using Aspire.Cli.Utils; +using Aspire.Hosting; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Aspire.Cli.Tests.Projects; + +public class AppHostServerSessionTests +{ + [Fact] + public async Task Start_DoesNotMutateCallerEnvironmentVariables() + { + // Arrange + var project = new RecordingAppHostServerProject(); + var environmentVariables = new Dictionary + { + ["EXISTING_VALUE"] = "present" + }; + + // Act + await using var session = AppHostServerSession.Start( + project, + environmentVariables, + debug: false, + NullLogger.Instance); + + // Assert + Assert.Equal("present", environmentVariables["EXISTING_VALUE"]); + Assert.False(environmentVariables.ContainsKey(KnownConfigNames.RemoteAppHostToken)); + + Assert.NotNull(project.ReceivedEnvironmentVariables); + Assert.Equal("present", project.ReceivedEnvironmentVariables["EXISTING_VALUE"]); + Assert.Equal(session.AuthenticationToken, project.ReceivedEnvironmentVariables[KnownConfigNames.RemoteAppHostToken]); + } + + private sealed class RecordingAppHostServerProject : IAppHostServerProject + { + public string AppDirectoryPath => Directory.GetCurrentDirectory(); + + public Dictionary? ReceivedEnvironmentVariables { get; private set; } + + public string GetInstanceIdentifier() => AppDirectoryPath; + + public Task PrepareAsync( + string sdkVersion, + IEnumerable integrations, + CancellationToken cancellationToken = default) => + throw new NotSupportedException(); + + public (string SocketPath, Process Process, OutputCollector OutputCollector) Run( + int hostPid, + IReadOnlyDictionary? environmentVariables = null, + string[]? additionalArgs = null, + bool debug = false) + { + ReceivedEnvironmentVariables = environmentVariables is null + ? null + : new Dictionary(environmentVariables); + + var process = Process.Start(new ProcessStartInfo("dotnet", "--version") + { + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false + })!; + + return ("test.sock", process, new OutputCollector()); + } + } +} diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/AtsGeneratedAspire.verified.go b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/AtsGeneratedAspire.verified.go index a14a280e0bd..b47ff5fc31c 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/AtsGeneratedAspire.verified.go +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/AtsGeneratedAspire.verified.go @@ -1395,6 +1395,13 @@ func Connect() (*AspireClient, error) { if err := client.Connect(); err != nil { return nil, err } + authToken := os.Getenv("ASPIRE_REMOTE_APPHOST_TOKEN") + if authToken == "" { + return nil, fmt.Errorf("ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`") + } + if err := client.Authenticate(authToken); err != nil { + return nil, err + } client.OnDisconnect(func() { os.Exit(1) }) return client, nil } diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go index f98e4db0566..215bc231ff3 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go @@ -17419,6 +17419,13 @@ func Connect() (*AspireClient, error) { if err := client.Connect(); err != nil { return nil, err } + authToken := os.Getenv("ASPIRE_REMOTE_APPHOST_TOKEN") + if authToken == "" { + return nil, fmt.Errorf("ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`") + } + if err := client.Authenticate(authToken); err != nil { + return nil, err + } client.OnDisconnect(func() { os.Exit(1) }) return client, nil } diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/AtsJavaCodeGeneratorTests.cs b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/AtsJavaCodeGeneratorTests.cs index 6011fd89647..2deedf55f87 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/AtsJavaCodeGeneratorTests.cs +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/AtsJavaCodeGeneratorTests.cs @@ -35,6 +35,7 @@ public async Task GenerateDistributedApplication_WithTestTypes_GeneratesCorrectO Assert.Contains("Aspire.java", files.Keys); Assert.Contains("Transport.java", files.Keys); Assert.Contains("Base.java", files.Keys); + Assert.Contains("List params = List.of(token);", files["Transport.java"]); await Verify(files["Aspire.java"], extension: "java") .UseFileName("AtsGeneratedAspire"); diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/AtsGeneratedAspire.verified.java b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/AtsGeneratedAspire.verified.java index b24fe84b254..d53cc53ceff 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/AtsGeneratedAspire.verified.java +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/AtsGeneratedAspire.verified.java @@ -984,6 +984,11 @@ public static AspireClient connect() throws Exception { } AspireClient client = new AspireClient(socketPath); client.connect(); + String authToken = System.getenv("ASPIRE_REMOTE_APPHOST_TOKEN"); + if (authToken == null || authToken.isEmpty()) { + throw new RuntimeException("ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`."); + } + client.authenticate(authToken); client.onDisconnect(() -> System.exit(1)); return client; } diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java index 0120e347841..37325d58db8 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java @@ -11877,6 +11877,11 @@ public static AspireClient connect() throws Exception { } AspireClient client = new AspireClient(socketPath); client.connect(); + String authToken = System.getenv("ASPIRE_REMOTE_APPHOST_TOKEN"); + if (authToken == null || authToken.isEmpty()) { + throw new RuntimeException("ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`."); + } + client.authenticate(authToken); client.onDisconnect(() -> System.exit(1)); return client; } diff --git a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/AtsGeneratedAspire.verified.py b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/AtsGeneratedAspire.verified.py index d84dd4677a6..88bd0794508 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/AtsGeneratedAspire.verified.py +++ b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/AtsGeneratedAspire.verified.py @@ -724,6 +724,10 @@ def connect() -> AspireClient: raise RuntimeError("REMOTE_APP_HOST_SOCKET_PATH environment variable not set. Run this application using `aspire run`.") client = AspireClient(socket_path) client.connect() + auth_token = os.environ.get("ASPIRE_REMOTE_APPHOST_TOKEN") + if not auth_token: + raise RuntimeError("ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`.") + client.authenticate(auth_token) client.on_disconnect(lambda: sys.exit(1)) return client diff --git a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py index a79bac2a416..1ed8d96fecd 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py +++ b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py @@ -8664,6 +8664,10 @@ def connect() -> AspireClient: raise RuntimeError("REMOTE_APP_HOST_SOCKET_PATH environment variable not set. Run this application using `aspire run`.") client = AspireClient(socket_path) client.connect() + auth_token = os.environ.get("ASPIRE_REMOTE_APPHOST_TOKEN") + if not auth_token: + raise RuntimeError("ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`.") + client.authenticate(auth_token) client.on_disconnect(lambda: sys.exit(1)) return client diff --git a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/AtsGeneratedAspire.verified.rs b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/AtsGeneratedAspire.verified.rs index 9fc7729a4dd..ee7bd5fa177 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/AtsGeneratedAspire.verified.rs +++ b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/AtsGeneratedAspire.verified.rs @@ -1301,6 +1301,9 @@ pub fn connect() -> Result, Box> { .map_err(|_| "REMOTE_APP_HOST_SOCKET_PATH environment variable not set. Run this application using `aspire run`")?; let client = Arc::new(AspireClient::new(&socket_path)); client.connect()?; + let auth_token = std::env::var("ASPIRE_REMOTE_APPHOST_TOKEN") + .map_err(|_| "ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`")?; + client.authenticate(&auth_token)?; Ok(client) } diff --git a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs index b79ba11edd0..d1ba5360ef7 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs +++ b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs @@ -14935,6 +14935,9 @@ pub fn connect() -> Result, Box> { .map_err(|_| "REMOTE_APP_HOST_SOCKET_PATH environment variable not set. Run this application using `aspire run`")?; let client = Arc::new(AspireClient::new(&socket_path)); client.connect()?; + let auth_token = std::env::var("ASPIRE_REMOTE_APPHOST_TOKEN") + .map_err(|_| "ASPIRE_REMOTE_APPHOST_TOKEN environment variable not set. Run this application using `aspire run`")?; + client.authenticate(&auth_token)?; Ok(client) } diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.JsTests/tests/transport.test.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.JsTests/tests/transport.test.ts index 14e39268a7e..8a157d9ec2c 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.JsTests/tests/transport.test.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.JsTests/tests/transport.test.ts @@ -465,6 +465,36 @@ describe('AspireClient', () => { const client = new AspireClient('nonexistent-pipe-' + Date.now()); await expect(client.connect(500)).rejects.toThrow(); }); + + it('sends the authentication token as a direct parameter during connect', async () => { + const previousToken = process.env.ASPIRE_REMOTE_APPHOST_TOKEN; + const authenticate = vi.fn(async (token: string) => { + expect(token).toBe('secret-token'); + return true; + }); + + process.env.ASPIRE_REMOTE_APPHOST_TOKEN = 'secret-token'; + + const fixture = createPipeFixture({ authenticate }); + await fixture.start(); + + const client = new AspireClient(fixture.clientSocketPath); + + try { + await client.connect(); + await fixture.waitForClient(); + + expect(authenticate).toHaveBeenCalledOnce(); + } finally { + if (previousToken === undefined) { + delete process.env.ASPIRE_REMOTE_APPHOST_TOKEN; + } else { + process.env.ASPIRE_REMOTE_APPHOST_TOKEN = previousToken; + } + + await fixture.cleanup(client); + } + }); }); // ============================================================================ @@ -540,7 +570,7 @@ describe('registerHandleWrapper', () => { * Creates a named-pipe server that speaks JSON-RPC, connects an AspireClient, * and provides a `sendRequest` helper to invoke callbacks on the client side. */ -function createPipeFixture() { +function createPipeFixture(options?: { authenticate?: (token: string) => boolean | Promise }) { const pipeName = `aspire-test-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`; const pipePath = process.platform === 'win32' ? `\\\\.\\pipe\\${pipeName}` : `/tmp/${pipeName}`; let serverConnection: rpc.MessageConnection | null = null; @@ -563,6 +593,10 @@ function createPipeFixture() { // Handle cancelToken serverConnection.onRequest('cancelToken', () => true); + if (options?.authenticate) { + serverConnection.onRequest('authenticate', options.authenticate); + } + serverConnection.listen(); onClientConnected?.(); }); @@ -591,12 +625,48 @@ function createPipeFixture() { describe('callback invocation protocol', () => { async function connectFixture() { - const fixture = createPipeFixture(); + const previousToken = process.env.ASPIRE_REMOTE_APPHOST_TOKEN; + const testToken = 'callback-test-token'; + process.env.ASPIRE_REMOTE_APPHOST_TOKEN = testToken; + + const fixture = createPipeFixture({ + authenticate: (token: string) => token === testToken, + }); + await fixture.start(); const client = new AspireClient(fixture.clientSocketPath); - await client.connect(); - await fixture.waitForClient(); - return { fixture, client }; + + try { + await client.connect(); + await fixture.waitForClient(); + } + catch (error) + { + if (previousToken === undefined) { + delete process.env.ASPIRE_REMOTE_APPHOST_TOKEN; + } else { + process.env.ASPIRE_REMOTE_APPHOST_TOKEN = previousToken; + } + + await fixture.cleanup(client); + throw error; + } + + return { + fixture: { + ...fixture, + cleanup: async (client: AspireClient) => { + if (previousToken === undefined) { + delete process.env.ASPIRE_REMOTE_APPHOST_TOKEN; + } else { + process.env.ASPIRE_REMOTE_APPHOST_TOKEN = previousToken; + } + + await fixture.cleanup(client); + }, + }, + client, + }; } it('invokes a no-arg callback', async () => { diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts index 3df2a47d497..6d29cf289d9 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/transport.verified.ts @@ -1,4 +1,4 @@ -// transport.ts - ATS transport layer: RPC, Handle, errors, callbacks +// transport.ts - ATS transport layer: RPC, Handle, errors, callbacks import * as net from 'net'; import * as rpc from 'vscode-jsonrpc/node.js'; @@ -830,7 +830,7 @@ export class AspireClient { failConnect(new Error('Connection closed before JSON-RPC was established')); }; - const onConnect = () => { + const onConnect = async () => { if (settled) { return; } @@ -867,7 +867,16 @@ export class AspireClient { 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; diff --git a/tests/Aspire.Hosting.RemoteHost.Tests/JsonRpcAuthenticationTests.cs b/tests/Aspire.Hosting.RemoteHost.Tests/JsonRpcAuthenticationTests.cs new file mode 100644 index 00000000000..789d0c18652 --- /dev/null +++ b/tests/Aspire.Hosting.RemoteHost.Tests/JsonRpcAuthenticationTests.cs @@ -0,0 +1,244 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.IO.Pipes; +using System.Net.Sockets; +using System.Text.Json; +using Aspire.Hosting.RemoteHost.Ats; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using StreamJsonRpc; +using Xunit; + +namespace Aspire.Hosting.RemoteHost.Tests; + +public sealed class JsonRpcAuthenticationTests +{ + public static TheoryData ProtectedMethods => new() + { + { "cancelToken", ["ct_missing"] }, + { "invokeCapability", ["test-capability", null] }, + { "getCapabilities", [] }, + { "generateCode", ["TypeScript"] }, + { "scaffoldAppHost", ["TypeScript", "/tmp/apphost", "AppHost"] }, + { "detectAppHostType", ["/tmp/apphost"] }, + { "getRuntimeSpec", ["TypeScript"] } + }; + + [Fact] + public async Task Ping_DoesNotRequireAuthentication() + { + await using var server = await RemoteHostTestServer.StartAsync(); + await using var client = await server.ConnectAsync(); + + var result = await client.InvokeAsync("ping"); + + Assert.Equal("pong", result); + } + + [Theory] + [MemberData(nameof(ProtectedMethods))] + public async Task ProtectedMethods_RequireAuthentication(string methodName, object?[] arguments) + { + await using var server = await RemoteHostTestServer.StartAsync(); + await using var client = await server.ConnectAsync(); + + var ex = await Assert.ThrowsAsync( + () => client.InvokeAsync(methodName, arguments)); + + Assert.Contains("Client must authenticate before invoking AppHost RPC methods.", ex.Message); + } + + [Fact] + public async Task FailedAuthentication_ClosesConnection_AndPreventsFurtherCalls() + { + await using var server = await RemoteHostTestServer.StartAsync(); + await using var client = await server.ConnectAsync(); + + Assert.Equal("pong", await client.InvokeAsync("ping")); + + await AssertRejectedAuthenticationAsync(client); + await RemoteHostTestServer.WaitForDisconnectAsync(client); + + await Assert.ThrowsAnyAsync(() => client.InvokeAsync("ping")); + await Assert.ThrowsAnyAsync(() => client.InvokeAsync("cancelToken", ["ct_missing"])); + } + + private static async Task AssertRejectedAuthenticationAsync(JsonRpcClientHandle client) + { + try + { + var authenticated = await client.InvokeAsync("authenticate", ["wrong-token"]); + Assert.False(authenticated); + } + catch (ConnectionLostException) + { + // The server closes the connection immediately after rejecting the token, so the client may observe + // the disconnect before it receives the boolean response. + } + } + + private sealed class RemoteHostTestServer : IAsyncDisposable + { + private const string RemoteAppHostToken = "ASPIRE_REMOTE_APPHOST_TOKEN"; + private readonly IHost _host; + private readonly string _socketPath; + private readonly string? _socketDirectory; + + private RemoteHostTestServer(IHost host, string socketPath, string? socketDirectory) + { + _host = host; + _socketPath = socketPath; + _socketDirectory = socketDirectory; + } + + public static async Task StartAsync() + { + var socketDirectory = OperatingSystem.IsWindows() + ? null + : Path.Combine(Path.GetTempPath(), $"arh-{Guid.NewGuid():N}"[..12]); + + if (socketDirectory is not null) + { + Directory.CreateDirectory(socketDirectory); + } + + var socketPath = OperatingSystem.IsWindows() + ? $"aspire-remotehost-test-{Guid.NewGuid():N}" + : Path.Combine(socketDirectory!, "rpc.sock"); + + var builder = Host.CreateApplicationBuilder(); + builder.Configuration.AddInMemoryCollection(new Dictionary + { + ["REMOTE_APP_HOST_SOCKET_PATH"] = socketPath, + [RemoteAppHostToken] = "expected-token" + }); + + ConfigureServices(builder.Services); + + var host = builder.Build(); + await host.StartAsync(); + + return new RemoteHostTestServer(host, socketPath, socketDirectory); + } + + public async Task ConnectAsync() + { + var stream = await ConnectToServerAsync(_socketPath, CancellationToken.None); + var formatter = new SystemTextJsonFormatter(); + var handler = new HeaderDelimitedMessageHandler(stream, stream, formatter); + var rpc = new JsonRpc(handler); + rpc.StartListening(); + + return new JsonRpcClientHandle(stream, rpc); + } + + public static async Task WaitForDisconnectAsync(JsonRpcClientHandle client) + { + var completedTask = await Task.WhenAny(client.Completion, Task.Delay(TimeSpan.FromSeconds(5))); + Assert.Same(client.Completion, completedTask); + } + + public async ValueTask DisposeAsync() + { + await _host.StopAsync(); + _host.Dispose(); + + if (!OperatingSystem.IsWindows() && File.Exists(_socketPath)) + { + File.Delete(_socketPath); + } + + if (!string.IsNullOrEmpty(_socketDirectory) && Directory.Exists(_socketDirectory)) + { + Directory.Delete(_socketDirectory, recursive: true); + } + } + + private static void ConfigureServices(IServiceCollection services) + { + services.AddHostedService(); + + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(sp => sp.GetRequiredService().GetContext()); + services.AddSingleton(); + services.AddScoped(); + services.AddSingleton(); + services.AddScoped(); + + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(sp => sp.GetRequiredService()); + services.AddScoped(); + services.AddScoped(sp => new Lazy(() => sp.GetRequiredService())); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + } + + private static async Task ConnectToServerAsync(string socketPath, CancellationToken cancellationToken) + { + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); + + Exception? lastException = null; + + while (!linkedCts.Token.IsCancellationRequested) + { + try + { + if (OperatingSystem.IsWindows()) + { + var pipeClient = new NamedPipeClientStream(".", socketPath, PipeDirection.InOut, PipeOptions.Asynchronous); + await pipeClient.ConnectAsync(linkedCts.Token); + return pipeClient; + } + + var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified); + await socket.ConnectAsync(new UnixDomainSocketEndPoint(socketPath), linkedCts.Token); + return new NetworkStream(socket, ownsSocket: true); + } + catch (Exception ex) when (ex is IOException or SocketException or TimeoutException or OperationCanceledException) + { + lastException = ex; + + if (timeoutCts.IsCancellationRequested) + { + break; + } + + await Task.Delay(100, cancellationToken); + } + } + + throw new TimeoutException($"Timed out connecting to test RPC server '{socketPath}'.", lastException); + } + } + + private sealed class JsonRpcClientHandle : IAsyncDisposable + { + private readonly Stream _stream; + private readonly JsonRpc _rpc; + + public JsonRpcClientHandle(Stream stream, JsonRpc rpc) + { + _stream = stream; + _rpc = rpc; + } + + public Task Completion => _rpc.Completion; + + public Task InvokeAsync(string methodName, params object?[] arguments) + => _rpc.InvokeWithCancellationAsync(methodName, arguments, CancellationToken.None); + + public async ValueTask DisposeAsync() + { + _rpc.Dispose(); + await _stream.DisposeAsync(); + } + } +} From 1465179b55f28e811a4b0545a0f600cd17e42155 Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Thu, 19 Mar 2026 00:25:59 -0400 Subject: [PATCH 13/49] Clean up Aspire panel: context menus, loading state, welcome messages (#15375) * Clean up Aspire panel: context menus, loading state, welcome messages Adds initial 'loading' screen, new context menus for resources, endpoints, apphost, and PID nodes. Consolidates previous 3 commits into one for clean rebase onto main. * remove unused strings * remove comands on resources node, update string --- extension/loc/xlf/aspire-vscode.xlf | 25 ++++- extension/package.json | 95 ++++++++++++++++--- extension/package.nls.json | 11 ++- extension/src/extension.ts | 6 +- extension/src/loc/strings.ts | 3 - extension/src/views/AppHostDataRepository.ts | 35 ++++++- .../src/views/AspireAppHostTreeProvider.ts | 33 +++++-- 7 files changed, 173 insertions(+), 35 deletions(-) diff --git a/extension/loc/xlf/aspire-vscode.xlf b/extension/loc/xlf/aspire-vscode.xlf index 4e54b113696..b40d4578b74 100644 --- a/extension/loc/xlf/aspire-vscode.xlf +++ b/extension/loc/xlf/aspire-vscode.xlf @@ -88,9 +88,18 @@ Controls what happens with the Aspire Dashboard when debugging starts. + + Copy ID + Copy URL + + Copy apphost path + + + Copy resource name + Create a new project @@ -280,6 +289,9 @@ No running Aspire apphost detected in this workspace. [Refresh](command:aspire-vscode.refreshRunningAppHosts) + + No running Aspire apphosts detected on this machine. [Refresh](command:aspire-vscode.refreshRunningAppHosts) + No watch task found. Please ensure a watch task is defined in your workspace. @@ -304,11 +316,11 @@ Open global Aspire settings - - Open in External Browser - - Open in Simple Browser + Open in VS Code + + + Open in browser Open local Aspire settings @@ -358,6 +370,9 @@ Scaffold a new Aspire project from a starter template. The template includes an apphost orchestrator, a sample API, and a web frontend. [Create new project](command:aspire-vscode.new) + + Searching for running apphosts... + See CLI installation instructions @@ -374,7 +389,7 @@ Show a notification with a link to open the dashboard. - Show global apphosts + Show all running apphosts Show workspace apphost diff --git a/extension/package.json b/extension/package.json index 52a46d94c47..0497a53ab05 100644 --- a/extension/package.json +++ b/extension/package.json @@ -63,15 +63,25 @@ ] }, "viewsWelcome": [ + { + "view": "aspire-vscode.runningAppHosts", + "contents": "%views.runningAppHosts.loading%", + "when": "aspire.loading" + }, { "view": "aspire-vscode.runningAppHosts", "contents": "%views.runningAppHosts.welcome%", - "when": "aspire.noRunningAppHosts && !aspire.fetchAppHostsError" + "when": "aspire.noRunningAppHosts && !aspire.fetchAppHostsError && !aspire.loading && aspire.viewMode != global" + }, + { + "view": "aspire-vscode.runningAppHosts", + "contents": "%views.runningAppHosts.globalWelcome%", + "when": "aspire.noRunningAppHosts && !aspire.fetchAppHostsError && !aspire.loading && aspire.viewMode == global" }, { "view": "aspire-vscode.runningAppHosts", "contents": "%views.runningAppHosts.errorWelcome%", - "when": "aspire.fetchAppHostsError" + "when": "aspire.fetchAppHostsError && !aspire.loading" } ], "debuggers": [ @@ -280,6 +290,24 @@ "category": "Aspire", "icon": "$(browser)" }, + { + "command": "aspire-vscode.copyAppHostPath", + "title": "%command.copyAppHostPath%", + "category": "Aspire", + "icon": "$(clippy)" + }, + { + "command": "aspire-vscode.copyResourceName", + "title": "%command.copyResourceName%", + "category": "Aspire", + "icon": "$(clippy)" + }, + { + "command": "aspire-vscode.copyPid", + "title": "%command.copyPid%", + "category": "Aspire", + "icon": "$(clippy)" + }, { "command": "aspire-vscode.switchToGlobalView", "title": "%command.switchToGlobalView%", @@ -395,6 +423,30 @@ { "command": "aspire-vscode.switchToWorkspaceView", "when": "false" + }, + { + "command": "aspire-vscode.copyEndpointUrl", + "when": "false" + }, + { + "command": "aspire-vscode.openInExternalBrowser", + "when": "false" + }, + { + "command": "aspire-vscode.openInSimpleBrowser", + "when": "false" + }, + { + "command": "aspire-vscode.copyAppHostPath", + "when": "false" + }, + { + "command": "aspire-vscode.copyResourceName", + "when": "false" + }, + { + "command": "aspire-vscode.copyPid", + "when": "false" } ], "view/title": [ @@ -425,6 +477,11 @@ "when": "view == aspire-vscode.runningAppHosts && viewItem == appHost", "group": "2_actions@1" }, + { + "command": "aspire-vscode.copyAppHostPath", + "when": "view == aspire-vscode.runningAppHosts && viewItem == appHost", + "group": "3_clipboard@1" + }, { "command": "aspire-vscode.stopResource", "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource.*:canStop/", @@ -440,30 +497,40 @@ "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource.*:canRestart/", "group": "2_actions@3" }, - { - "command": "aspire-vscode.viewResourceLogs", - "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource/", - "group": "3_logs@1" - }, { "command": "aspire-vscode.executeResourceCommand", - "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource/", - "group": "4_commands@1" + "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource(:|$)/", + "group": "2_actions@4" }, { - "command": "aspire-vscode.copyEndpointUrl", - "when": "view == aspire-vscode.runningAppHosts && viewItem == endpointUrl", - "group": "1_clipboard@1" + "command": "aspire-vscode.viewResourceLogs", + "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource(:|$)/", + "group": "3_info@1" }, { "command": "aspire-vscode.openInExternalBrowser", "when": "view == aspire-vscode.runningAppHosts && viewItem == endpointUrl", - "group": "2_open@1" + "group": "1_open@1" }, { "command": "aspire-vscode.openInSimpleBrowser", "when": "view == aspire-vscode.runningAppHosts && viewItem == endpointUrl", - "group": "2_open@2" + "group": "1_open@2" + }, + { + "command": "aspire-vscode.copyEndpointUrl", + "when": "view == aspire-vscode.runningAppHosts && viewItem == endpointUrl", + "group": "3_clipboard@1" + }, + { + "command": "aspire-vscode.copyResourceName", + "when": "view == aspire-vscode.runningAppHosts && viewItem =~ /^resource(:|$)/", + "group": "3_info@2" + }, + { + "command": "aspire-vscode.copyPid", + "when": "view == aspire-vscode.runningAppHosts && viewItem == pidItem", + "group": "1_clipboard@1" } ] }, diff --git a/extension/package.nls.json b/extension/package.nls.json index 568f73a5b6e..693a4a15529 100644 --- a/extension/package.nls.json +++ b/extension/package.nls.json @@ -117,7 +117,9 @@ "aspire-vscode.strings.enterPipelineStep": "Enter the pipeline step to execute", "viewsContainers.aspirePanel.title": "Aspire", "views.runningAppHosts.name": "Running AppHosts", + "views.runningAppHosts.loading": "Searching for running apphosts...", "views.runningAppHosts.welcome": "No running Aspire apphost detected in this workspace.\n[Refresh](command:aspire-vscode.refreshRunningAppHosts)", + "views.runningAppHosts.globalWelcome": "No running Aspire apphosts detected on this machine.\n[Refresh](command:aspire-vscode.refreshRunningAppHosts)", "views.runningAppHosts.errorWelcome": "The Aspire CLI is not installed or does not support this feature. Install or update the Aspire CLI and restart VS Code to get started.\n[Update Aspire CLI](command:aspire-vscode.updateSelf)\n[Refresh](command:aspire-vscode.refreshRunningAppHosts)", "command.refreshRunningAppHosts": "Refresh running apphosts", "command.openDashboard": "Open Dashboard", @@ -128,9 +130,12 @@ "command.viewResourceLogs": "View logs", "command.executeResourceCommand": "Execute resource command", "command.copyEndpointUrl": "Copy URL", - "command.openInExternalBrowser": "Open in External Browser", - "command.openInSimpleBrowser": "Open in Simple Browser", - "command.switchToGlobalView": "Show global apphosts", + "command.openInExternalBrowser": "Open in browser", + "command.openInSimpleBrowser": "Open in VS Code", + "command.copyAppHostPath": "Copy apphost path", + "command.copyResourceName": "Copy resource name", + "command.copyPid": "Copy ID", + "command.switchToGlobalView": "Show all running apphosts", "command.switchToWorkspaceView": "Show workspace apphost", "command.installCliStable": "Install Aspire CLI (stable)", "command.installCliDaily": "Install Aspire CLI (daily)", diff --git a/extension/src/extension.ts b/extension/src/extension.ts index b35db7e988c..b74c87365b8 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -100,14 +100,18 @@ export async function activate(context: vscode.ExtensionContext) { const copyEndpointUrlRegistration = vscode.commands.registerCommand('aspire-vscode.copyEndpointUrl', (element) => appHostTreeProvider.copyEndpointUrl(element)); const openInExternalBrowserRegistration = vscode.commands.registerCommand('aspire-vscode.openInExternalBrowser', (element) => appHostTreeProvider.openInExternalBrowser(element)); const openInSimpleBrowserRegistration = vscode.commands.registerCommand('aspire-vscode.openInSimpleBrowser', (element) => appHostTreeProvider.openInSimpleBrowser(element)); + const copyResourceNameRegistration = vscode.commands.registerCommand('aspire-vscode.copyResourceName', (element) => appHostTreeProvider.copyResourceName(element)); + const copyPidRegistration = vscode.commands.registerCommand('aspire-vscode.copyPid', (element) => appHostTreeProvider.copyPid(element)); + const copyAppHostPathRegistration = vscode.commands.registerCommand('aspire-vscode.copyAppHostPath', (element) => appHostTreeProvider.copyAppHostPath(element)); // Set initial context for welcome view vscode.commands.executeCommand('setContext', 'aspire.noRunningAppHosts', true); + vscode.commands.executeCommand('setContext', 'aspire.loading', true); // Activate the data repository (starts workspace describe --follow; global polling begins when the panel is visible) dataRepository.activate(); - context.subscriptions.push(appHostTreeView, refreshRunningAppHostsRegistration, switchToGlobalViewRegistration, switchToWorkspaceViewRegistration, openDashboardRegistration, stopAppHostRegistration, stopResourceRegistration, startResourceRegistration, restartResourceRegistration, viewResourceLogsRegistration, executeResourceCommandRegistration, copyEndpointUrlRegistration, openInExternalBrowserRegistration, openInSimpleBrowserRegistration, { dispose: () => { appHostTreeProvider.dispose(); dataRepository.dispose(); } }); + context.subscriptions.push(appHostTreeView, refreshRunningAppHostsRegistration, switchToGlobalViewRegistration, switchToWorkspaceViewRegistration, openDashboardRegistration, stopAppHostRegistration, stopResourceRegistration, startResourceRegistration, restartResourceRegistration, viewResourceLogsRegistration, executeResourceCommandRegistration, copyEndpointUrlRegistration, openInExternalBrowserRegistration, openInSimpleBrowserRegistration, copyResourceNameRegistration, copyPidRegistration, copyAppHostPathRegistration, { dispose: () => { appHostTreeProvider.dispose(); dataRepository.dispose(); } }); context.subscriptions.push(cliAddCommandRegistration, cliNewCommandRegistration, cliInitCommandRegistration, cliDeployCommandRegistration, cliPublishCommandRegistration, cliDoCommandRegistration, openTerminalCommandRegistration, configureLaunchJsonCommandRegistration); context.subscriptions.push(cliUpdateCommandRegistration, cliUpdateSelfCommandRegistration, settingsCommandRegistration, openLocalSettingsCommandRegistration, openGlobalSettingsCommandRegistration, runAppHostCommandRegistration, debugAppHostCommandRegistration); diff --git a/extension/src/loc/strings.ts b/extension/src/loc/strings.ts index 9df9e729ac9..d65d03d95f7 100644 --- a/extension/src/loc/strings.ts +++ b/extension/src/loc/strings.ts @@ -97,6 +97,3 @@ export const cliFoundAtDefaultPath = (path: string) => vscode.l10n.t('Aspire CLI export const selectDirectoryTitle = vscode.l10n.t('Select directory'); export const selectFileTitle = vscode.l10n.t('Select file'); export const enterPipelineStep = vscode.l10n.t('Enter the pipeline step to execute'); - -// Endpoint URL context menu strings -export const copiedUrlToClipboard = (url: string) => vscode.l10n.t('Copied {0} to clipboard', url); diff --git a/extension/src/views/AppHostDataRepository.ts b/extension/src/views/AppHostDataRepository.ts index 4bc63101fdf..a37df1b21dd 100644 --- a/extension/src/views/AppHostDataRepository.ts +++ b/extension/src/views/AppHostDataRepository.ts @@ -81,6 +81,10 @@ export class AppHostDataRepository { // ── Error state ── private _errorMessage: string | undefined; + // ── Loading state ── + private _loadingWorkspace = true; + private _loadingGlobal = true; + private readonly _configChangeDisposable: vscode.Disposable; private _disposed = false; @@ -131,6 +135,8 @@ export class AppHostDataRepository { } this._viewMode = mode; vscode.commands.executeCommand('setContext', 'aspire.viewMode', mode); + this._setError(undefined); + this._updateLoadingContext(); this._syncPolling(); this._onDidChangeData.fire(); } @@ -272,10 +278,11 @@ export class AppHostDataRepository { if (!this._disposed && !this._describeRestarting) { if (!this._describeReceivedData && code !== 0) { // The process exited with a non-zero code without ever producing valid data. - // This likely means the CLI does not support the describe command. - extensionLogOutputChannel.warn('aspire describe --follow exited without producing data; the installed Aspire CLI may not support this feature.'); + // This is expected when no apphost is running. Don't set the error state + // since that would show the "CLI not supported" banner; instead just show + // the normal "no running apphost" welcome. + extensionLogOutputChannel.warn('aspire describe --follow exited without producing data; no running apphost or CLI may not support this feature.'); this._workspaceResources.clear(); - this._setError(errorFetchingAppHosts(`exit code ${code}`)); this._updateWorkspaceContext(); } else { this._workspaceResources.clear(); @@ -300,12 +307,16 @@ export class AppHostDataRepository { extensionLogOutputChannel.warn(`aspire describe --follow error: ${error.message}`); this._describeProcess = undefined; if (!this._disposed && !this._describeRestarting) { + this._loadingWorkspace = false; + this._updateLoadingContext(); this._setError(errorFetchingAppHosts(error.message)); } } }); }).catch(error => { extensionLogOutputChannel.warn(`Failed to start describe watch: ${error}`); + this._loadingWorkspace = false; + this._updateLoadingContext(); this._setError(errorFetchingAppHosts(String(error))); }); } @@ -345,6 +356,10 @@ export class AppHostDataRepository { private _updateWorkspaceContext(): void { const hasResources = this._workspaceResources.size > 0; vscode.commands.executeCommand('setContext', 'aspire.noRunningAppHosts', !hasResources); + if (this._loadingWorkspace) { + this._loadingWorkspace = false; + this._updateLoadingContext(); + } this._onDidChangeData.fire(); } @@ -397,17 +412,26 @@ export class AppHostDataRepository { this._setError(undefined); this._handlePsOutput(retryStdout); } else { + this._loadingGlobal = false; + this._updateLoadingContext(); this._setError(errorFetchingAppHosts(retryStderr || `exit code ${retryCode}`)); } this._fetchInProgress = false; }); } else { + this._loadingGlobal = false; + this._updateLoadingContext(); this._setError(errorFetchingAppHosts(stderr || `exit code ${code}`)); this._fetchInProgress = false; } }); } + private _updateLoadingContext(): void { + const isLoading = this._viewMode === 'workspace' ? this._loadingWorkspace : this._loadingGlobal; + vscode.commands.executeCommand('setContext', 'aspire.loading', isLoading); + } + private _setError(message: string | undefined): void { const hasError = message !== undefined; if (this._errorMessage !== message) { @@ -426,6 +450,11 @@ export class AppHostDataRepository { const changed = JSON.stringify(parsed) !== JSON.stringify(this._appHosts); this._appHosts = parsed; + if (this._loadingGlobal) { + this._loadingGlobal = false; + this._updateLoadingContext(); + } + if (changed) { vscode.commands.executeCommand('setContext', 'aspire.noRunningAppHosts', parsed.length === 0); this._onDidChangeData.fire(); diff --git a/extension/src/views/AspireAppHostTreeProvider.ts b/extension/src/views/AspireAppHostTreeProvider.ts index 7c679176c1e..fd1c4738e24 100644 --- a/extension/src/views/AspireAppHostTreeProvider.ts +++ b/extension/src/views/AspireAppHostTreeProvider.ts @@ -15,7 +15,6 @@ import { tooltipState, tooltipHealth, tooltipEndpoints, - copiedUrlToClipboard, } from '../loc/strings'; import { AppHostDataRepository, @@ -24,7 +23,7 @@ import { shortenPath, } from './AppHostDataRepository'; -type TreeElement = AppHostItem | DetailItem | EndpointUrlItem | ResourcesGroupItem | ResourceItem | WorkspaceResourcesItem; +type TreeElement = AppHostItem | DetailItem | PidItem | EndpointUrlItem | ResourcesGroupItem | ResourceItem | WorkspaceResourcesItem; function sortResources(resources: ResourceJson[]): ResourceJson[] { return [...resources].sort((a, b) => { @@ -75,6 +74,14 @@ class DetailItem extends vscode.TreeItem { } } +class PidItem extends vscode.TreeItem { + constructor(public readonly pid: number, label: string, icon: string) { + super(label, vscode.TreeItemCollapsibleState.None); + this.iconPath = new vscode.ThemeIcon(icon); + this.contextValue = 'pidItem'; + } +} + class EndpointUrlItem extends vscode.TreeItem { constructor(public readonly url: string, displayName: string) { super(displayName, vscode.TreeItemCollapsibleState.None); @@ -271,20 +278,22 @@ export class AspireAppHostTreeProvider implements vscode.TreeDataProvider { + await vscode.env.clipboard.writeText(element.appHost.appHostPath); + } + async copyEndpointUrl(element: EndpointUrlItem): Promise { await vscode.env.clipboard.writeText(element.url); - vscode.window.showInformationMessage(copiedUrlToClipboard(element.url)); + } + + async copyResourceName(element: ResourceItem): Promise { + const name = element.resource.displayName ?? element.resource.name; + await vscode.env.clipboard.writeText(name); + } + + async copyPid(element: PidItem): Promise { + await vscode.env.clipboard.writeText(element.pid.toString()); } openInExternalBrowser(element: EndpointUrlItem): void { From b70a3e0c9afc2e7518fd595e9a56d942276f59bd Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 19 Mar 2026 11:50:00 -0500 Subject: [PATCH 14/49] Stablize Aspire.Hosting.Azure Network and Sql packages (#15394) Use stable Azure.Provisioning.PrivateDns and remove SuppressFinalPackageVersion on these two packages so they ship stable. Fix #15328 --- Directory.Packages.props | 4 ++-- .../Aspire.Hosting.Azure.Network.csproj | 3 --- src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj | 3 --- tests/Shared/RepoTesting/Directory.Packages.Helix.props | 3 ++- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 025ef73d7a4..06d000e49fc 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -38,7 +38,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj b/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj index 61e6b282c7e..dc9b9da99dc 100644 --- a/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj +++ b/src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj @@ -6,9 +6,6 @@ aspire integration hosting azure network vnet virtual-network subnet nat-gateway public-ip cloud Azure Virtual Network resource types for Aspire. $(SharedDir)Azure_256x.png - - true true $(NoWarn);AZPROVISION001;ASPIREAZURE003 diff --git a/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj b/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj index dfb9a374f5c..b5a93be6e67 100644 --- a/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj +++ b/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj @@ -7,9 +7,6 @@ aspire integration hosting azure sql database data cloud Azure SQL Database resource types for Aspire. $(SharedDir)AzureSqlServer_256x.png - - true diff --git a/tests/Shared/RepoTesting/Directory.Packages.Helix.props b/tests/Shared/RepoTesting/Directory.Packages.Helix.props index d7a1766e843..dbeeab88840 100644 --- a/tests/Shared/RepoTesting/Directory.Packages.Helix.props +++ b/tests/Shared/RepoTesting/Directory.Packages.Helix.props @@ -25,13 +25,14 @@ + - + From ae1573983340eb7d8f07d009d09b2957d659bddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 19 Mar 2026 09:51:08 -0700 Subject: [PATCH 15/49] Update Foundry models (#15389) --- .../FoundryModel.Generated.cs | 14 +- .../FoundryModel.Local.Generated.cs | 134 +++++++++++++++++- 2 files changed, 145 insertions(+), 3 deletions(-) diff --git a/src/Aspire.Hosting.Foundry/FoundryModel.Generated.cs b/src/Aspire.Hosting.Foundry/FoundryModel.Generated.cs index 5c1d87d32a7..9ee5890a0fb 100644 --- a/src/Aspire.Hosting.Foundry/FoundryModel.Generated.cs +++ b/src/Aspire.Hosting.Foundry/FoundryModel.Generated.cs @@ -44,7 +44,7 @@ public static partial class Anthropic public static readonly FoundryModel ClaudeOpus45 = new() { Name = "claude-opus-4-5", Version = "20251101", Format = "Anthropic" }; /// - /// Claude Opus 4.6 is the latest version of Anthropic's most intelligent model, and the world's best model for coding, enterprise agents, and professional work. With a 1M token context window (beta) and 128K max output, Opus 4.6 is ideal for production code, + /// Claude Opus 4.6 is the latest version of Anthropic's most intelligent model, and the world's best model for coding, enterprise agents, and professional work. With a 1M token context window and 128K max output, Opus 4.6 is ideal for production code, sophist /// public static readonly FoundryModel ClaudeOpus46 = new() { Name = "claude-opus-4-6", Version = "1", Format = "Anthropic" }; @@ -54,7 +54,7 @@ public static partial class Anthropic public static readonly FoundryModel ClaudeSonnet45 = new() { Name = "claude-sonnet-4-5", Version = "20250929", Format = "Anthropic" }; /// - /// Claude Sonnet 4.6 delivers frontier intelligence at scale—built for coding, agents, and enterprise workflows. With a 1M token context window (beta) and 128K max output, Sonnet 4.6 is ideal for coding, agents, office tasks, financial analysis, cybersecurity + /// Claude Sonnet 4.6 delivers frontier intelligence at scale—built for coding, agents, and enterprise workflows. With a 1M token context window and 128K max output, Sonnet 4.6 is ideal for coding, agents, office tasks, financial analysis, cybersecurity, and c /// public static readonly FoundryModel ClaudeSonnet46 = new() { Name = "claude-sonnet-4-6", Version = "1", Format = "Anthropic" }; } @@ -2785,6 +2785,16 @@ public static partial class OpenAI /// public static readonly FoundryModel Gpt54 = new() { Name = "gpt-5.4", Version = "2026-03-05", Format = "OpenAI" }; + /// + /// GPT‑5.4‑mini is a compact, cost‑efficient model designed for reliable performance across high‑volume, everyday AI workloads. + /// + public static readonly FoundryModel Gpt54Mini = new() { Name = "gpt-5.4-mini", Version = "2026-03-17", Format = "OpenAI" }; + + /// + /// GPT‑5.4‑nano is a lightweight, ultra‑efficient model designed for low‑latency, cost‑effective tasks at massive scale. + /// + public static readonly FoundryModel Gpt54Nano = new() { Name = "gpt-5.4-nano", Version = "2026-03-17", Format = "OpenAI" }; + /// /// GPT‑5.4-Pro is OpenAI’s most capable frontier model, built to deliver faster, more reliable results for complex professional work. /// diff --git a/src/Aspire.Hosting.Foundry/FoundryModel.Local.Generated.cs b/src/Aspire.Hosting.Foundry/FoundryModel.Local.Generated.cs index 23b47cb2b35..d9e508d0a52 100644 --- a/src/Aspire.Hosting.Foundry/FoundryModel.Local.Generated.cs +++ b/src/Aspire.Hosting.Foundry/FoundryModel.Local.Generated.cs @@ -896,7 +896,95 @@ public static partial class Local /// /// See Hugging Face model Qwen3-0.6B for details. /// - public static readonly FoundryModel Qwen306b = new() { Name = "qwen3-0.6b", Version = "2", Format = "Microsoft" }; + public static readonly FoundryModel Qwen306b = new() { Name = "qwen3-0.6b", Version = "1", Format = "Microsoft" }; + + /// + /// This model is an optimized version of Qwen3-1.7B to enable local inference. This model uses KLD Gradient quantization. + /// + /// Model Description + /// + /// + /// + /// + /// + /// Developed by: Microsoft + /// + /// + /// + /// + /// + /// Model type: ONNX + /// + /// + /// + /// + /// + /// License: apache-2.0 + /// + /// + /// + /// + /// + /// Model Description: This is a conversion of the Qwen3-1.7B for local inference. + /// + /// + /// + /// + /// + /// Disclaimer: Model is only an optimization of the base model, any risk associated with the model is the responsibility of the user of the model. Please verify and test for your scenarios. There may be a slight difference in output from the base model with the optimizations applied. Note that optimizations applied are distinct from fine tuning and thus do not alter the intended uses or capabilities of the model. + /// + /// + /// + /// + /// Base Model Information + /// + /// See Hugging Face model Qwen3-1.7B for details. + /// + public static readonly FoundryModel Qwen317b = new() { Name = "qwen3-1.7b", Version = "1", Format = "Microsoft" }; + + /// + /// This model is an optimized version of Qwen3-14B to enable local inference. This model uses GPTQ quantization. + /// + /// Model Description + /// + /// + /// + /// + /// + /// Developed by: Microsoft + /// + /// + /// + /// + /// + /// Model type: ONNX + /// + /// + /// + /// + /// + /// License: apache-2.0 + /// + /// + /// + /// + /// + /// Model Description: This is a conversion of the Qwen3-14B for local inference. + /// + /// + /// + /// + /// + /// Disclaimer: Model is only an optimization of the base model, any risk associated with the model is the responsibility of the user of the model. Please verify and test for your scenarios. There may be a slight difference in output from the base model with the optimizations applied. Note that optimizations applied are distinct from fine tuning and thus do not alter the intended uses or capabilities of the model. + /// + /// + /// + /// + /// Base Model Information + /// + /// See Hugging Face model Qwen3-14B for details. + /// + public static readonly FoundryModel Qwen314b = new() { Name = "qwen3-14b", Version = "1", Format = "Microsoft" }; /// /// This model is an optimized version of Qwen3-4B to enable local inference. This model uses KLD Gradient quantization. @@ -942,6 +1030,50 @@ public static partial class Local /// public static readonly FoundryModel Qwen34b = new() { Name = "qwen3-4b", Version = "1", Format = "Microsoft" }; + /// + /// This model is an optimized version of Qwen3-8B to enable local inference. This model uses KLD Gradient quantization. + /// + /// Model Description + /// + /// + /// + /// + /// + /// Developed by: Microsoft + /// + /// + /// + /// + /// + /// Model type: ONNX + /// + /// + /// + /// + /// + /// License: apache-2.0 + /// + /// + /// + /// + /// + /// Model Description: This is a conversion of the Qwen3-8B for local inference. + /// + /// + /// + /// + /// + /// Disclaimer: Model is only an optimization of the base model, any risk associated with the model is the responsibility of the user of the model. Please verify and test for your scenarios. There may be a slight difference in output from the base model with the optimizations applied. Note that optimizations applied are distinct from fine tuning and thus do not alter the intended uses or capabilities of the model. + /// + /// + /// + /// + /// Base Model Information + /// + /// See Hugging Face model Qwen3-8B for details. + /// + public static readonly FoundryModel Qwen38b = new() { Name = "qwen3-8b", Version = "1", Format = "Microsoft" }; + /// /// This model is an optimized version of Qwen3-VL-2B-Instruct to enable local inference. This model uses RTN quantization. /// From e26dbb5cd45ba556454137727112bcac38db5334 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 09:51:59 -0700 Subject: [PATCH 16/49] [release/13.2] Handle version selector in CPM CLI E2E test (#15395) * Fix brittle CPM CLI E2E test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Harden CPM E2E prompt handling Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Sebastien Ros Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CentralPackageManagementTests.cs | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/tests/Aspire.Cli.EndToEnd.Tests/CentralPackageManagementTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/CentralPackageManagementTests.cs index 266530766c3..099501c4689 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/CentralPackageManagementTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/CentralPackageManagementTests.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Xml.Linq; + using Aspire.Cli.EndToEnd.Tests.Helpers; using Aspire.Cli.Tests.Utils; using Hex1b.Automation; @@ -168,16 +170,55 @@ public async Task AspireAddPackageVersionToDirectoryPackagesProps() """); - await auto.TypeAsync($"aspire add Aspire.Hosting.Redis --version 13.1.2"); + var waitingForVersionSelection = new CellPatternSearcher() + .Find("Select a version of"); + var versionSelectionShown = false; + + await auto.TypeAsync("aspire add Aspire.Hosting.Redis"); await auto.EnterAsync(); + await auto.WaitUntilAsync(s => + { + if (waitingForVersionSelection.Search(s).Count > 0) + { + versionSelectionShown = true; + return true; + } + + var successPromptSearcher = new CellPatternSearcher() + .FindPattern(counter.Value.ToString()) + .RightText(" OK] $ "); + + return successPromptSearcher.Search(s).Count > 0; + }, timeout: TimeSpan.FromSeconds(180), description: "version selection prompt or success prompt"); + + if (versionSelectionShown) + { + // PR hives can surface multiple channels in CI. Accept the default implicit-channel version + // so this test validates CPM behavior without pinning a specific package version. + await auto.EnterAsync(); + } + await auto.WaitForSuccessPromptAsync(counter); - // Verify the PackageVersion for Aspire.Hosting.AppHost was removed + // Verify the AppHost project does not end up with a version-pinned Redis PackageReference. { - var content = File.ReadAllText(appHostCsprojPath); - if (content.Contains("Version=\"13.1.2\"")) + var appHostProject = XDocument.Load(appHostCsprojPath); + var hasVersionPinnedRedisReference = false; + + foreach (var element in appHostProject.Descendants()) + { + if (element.Name.LocalName == "PackageReference" && + string.Equals((string?)element.Attribute("Include"), "Aspire.Hosting.Redis", StringComparison.Ordinal) && + element.Attribute("Version") is not null) + { + hasVersionPinnedRedisReference = true; + break; + } + } + + if (hasVersionPinnedRedisReference) { - throw new InvalidOperationException($"File {appHostCsprojPath} unexpectedly contains: Version=\"13.1.2\""); + throw new InvalidOperationException($"File {appHostCsprojPath} unexpectedly contains a version-pinned PackageReference for Aspire.Hosting.Redis"); } } From 22edbe1fefed2391957d2610422864916d46ead8 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 19 Mar 2026 13:15:02 -0500 Subject: [PATCH 17/49] [release/13.2] API Review Feedback (#15370) * API Review Feedback Fixing some API review comments. * Remove unused attribute. --- .../AzureAppConfigurationResource.cs | 2 - .../AzureCosmosDBResource.cs | 2 - .../AzureEventHubsResource.cs | 2 - .../AzureKeyVaultResource.cs | 2 - .../AzurePrivateEndpointExtensions.cs | 1 - ...IAzurePrivateEndpointTargetNotification.cs | 2 +- .../AzurePostgresFlexibleServerResource.cs | 2 - .../AzureManagedRedisResource.cs | 2 - .../AzureSearchResource.cs | 2 - .../AzureServiceBusResource.cs | 2 - .../AzureSignalRResource.cs | 2 - .../AzureSqlServerResource.cs | 3 -- .../AzureWebPubSubResource.cs | 2 - .../Polyglot/PolyglotIgnoreAttribute.cs | 52 ------------------- .../Polyglot/PolyglotLanguages.cs | 35 ------------- 15 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 src/Aspire.Hosting/Polyglot/PolyglotIgnoreAttribute.cs delete mode 100644 src/Aspire.Hosting/Polyglot/PolyglotLanguages.cs diff --git a/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationResource.cs b/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationResource.cs index b3e11a7c663..6db2b8a2291 100644 --- a/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationResource.cs +++ b/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationResource.cs @@ -77,8 +77,6 @@ public override ProvisionableResource AddAsExistingResource(AzureResourceInfrast return store; } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["configurationStores"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.azconfig.io"; diff --git a/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs index 35ef66f13c7..0ccf61bc58b 100644 --- a/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs +++ b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs @@ -263,8 +263,6 @@ IEnumerable> IResourceWithConnectionSt } } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["Sql"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.documents.azure.com"; diff --git a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs index d41cf08fe33..717f7818fbc 100644 --- a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs +++ b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs @@ -213,8 +213,6 @@ IEnumerable> IResourceWithConnectionSt } } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["namespace"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.servicebus.windows.net"; diff --git a/src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResource.cs b/src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResource.cs index c070dd76ba0..e1371df42f2 100644 --- a/src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResource.cs +++ b/src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResource.cs @@ -147,8 +147,6 @@ IEnumerable> IResourceWithConnectionSt yield return new("Uri", UriExpression); } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["vault"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.vaultcore.azure.net"; diff --git a/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs b/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs index 2d6fa2bf668..afd5bbd2ca2 100644 --- a/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs +++ b/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs @@ -3,7 +3,6 @@ using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.Azure; -using Aspire.Hosting.Azure.Network; using Azure.Provisioning; using Azure.Provisioning.Network; using Azure.Provisioning.PrivateDns; diff --git a/src/Aspire.Hosting.Azure.Network/IAzurePrivateEndpointTargetNotification.cs b/src/Aspire.Hosting.Azure.Network/IAzurePrivateEndpointTargetNotification.cs index aa87e2c1b11..47c7a3a1c96 100644 --- a/src/Aspire.Hosting.Azure.Network/IAzurePrivateEndpointTargetNotification.cs +++ b/src/Aspire.Hosting.Azure.Network/IAzurePrivateEndpointTargetNotification.cs @@ -3,7 +3,7 @@ using Aspire.Hosting.ApplicationModel; -namespace Aspire.Hosting.Azure.Network; +namespace Aspire.Hosting.Azure; /// /// An optional interface that can be implemented by resources that are targets for diff --git a/src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresFlexibleServerResource.cs b/src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresFlexibleServerResource.cs index ee53b338bb7..795f822b45a 100644 --- a/src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresFlexibleServerResource.cs +++ b/src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresFlexibleServerResource.cs @@ -314,8 +314,6 @@ IEnumerable> IResourceWithConnectionSt return propertiesDictionary; } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["postgresqlServer"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.postgres.database.azure.com"; diff --git a/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs b/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs index 65f40b36bfc..3d7d92d3fc1 100644 --- a/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs +++ b/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs @@ -255,8 +255,6 @@ IEnumerable> IResourceWithConnectionSt } } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["redisEnterprise"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.redis.azure.net"; diff --git a/src/Aspire.Hosting.Azure.Search/AzureSearchResource.cs b/src/Aspire.Hosting.Azure.Search/AzureSearchResource.cs index b607946d586..01c1d91615c 100644 --- a/src/Aspire.Hosting.Azure.Search/AzureSearchResource.cs +++ b/src/Aspire.Hosting.Azure.Search/AzureSearchResource.cs @@ -91,8 +91,6 @@ IEnumerable> IResourceWithConnectionSt yield return new("Uri", UriExpression); } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["searchService"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.search.windows.net"; diff --git a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs index 332feb78b66..b7549ecca2c 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs +++ b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs @@ -193,8 +193,6 @@ IEnumerable> IResourceWithConnectionSt } } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["namespace"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.servicebus.windows.net"; diff --git a/src/Aspire.Hosting.Azure.SignalR/AzureSignalRResource.cs b/src/Aspire.Hosting.Azure.SignalR/AzureSignalRResource.cs index a38431efde0..bba2b89609f 100644 --- a/src/Aspire.Hosting.Azure.SignalR/AzureSignalRResource.cs +++ b/src/Aspire.Hosting.Azure.SignalR/AzureSignalRResource.cs @@ -94,8 +94,6 @@ IEnumerable> IResourceWithConnectionSt yield return new("Uri", UriExpression); } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["signalr"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.service.signalr.net"; diff --git a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs index 741586ad73e..513ab11617b 100644 --- a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs +++ b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs @@ -7,7 +7,6 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; using Aspire.Hosting.ApplicationModel; -using Aspire.Hosting.Azure.Network; using Aspire.Hosting.Eventing; using Aspire.Hosting.Pipelines; using Azure.Provisioning; @@ -439,8 +438,6 @@ IEnumerable> IResourceWithConnectionSt return result; } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["sqlServer"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.database.windows.net"; diff --git a/src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubResource.cs b/src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubResource.cs index 6869a8b0cc6..a60391fae13 100644 --- a/src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubResource.cs +++ b/src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubResource.cs @@ -81,8 +81,6 @@ IEnumerable> IResourceWithConnectionSt yield return new("Uri", UriExpression); } - BicepOutputReference IAzurePrivateEndpointTarget.Id => Id; - IEnumerable IAzurePrivateEndpointTarget.GetPrivateLinkGroupIds() => ["webpubsub"]; string IAzurePrivateEndpointTarget.GetPrivateDnsZoneName() => "privatelink.webpubsub.azure.com"; diff --git a/src/Aspire.Hosting/Polyglot/PolyglotIgnoreAttribute.cs b/src/Aspire.Hosting/Polyglot/PolyglotIgnoreAttribute.cs deleted file mode 100644 index 9395285b9ae..00000000000 --- a/src/Aspire.Hosting/Polyglot/PolyglotIgnoreAttribute.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Aspire.Hosting.Polyglot; - -/// -/// Marks a method or type as excluded from polyglot code generation. -/// -/// -/// Use this attribute to prevent specific methods, types, or properties from being included -/// in generated TypeScript/Python SDK bindings. This is useful for methods that: -/// -/// Have unsupported parameter types or signatures -/// Are intended only for internal use -/// Would create confusing or unnecessary API surface in guest languages -/// -/// -/// -/// -/// // This method will not appear in generated SDKs -/// [PolyglotIgnore] -/// public static IResourceBuilder<T> WithAdvancedConfiguration<T>( -/// this IResourceBuilder<T> builder, -/// Action<IConfiguration, IServiceProvider> configure); -/// -/// -[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] -public sealed class PolyglotIgnoreAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - public PolyglotIgnoreAttribute() - { - Languages = PolyglotLanguages.All; - } - - /// - /// Initializes a new instance of the class - /// for specific languages only. - /// - /// The languages for which this member should be ignored. - public PolyglotIgnoreAttribute(PolyglotLanguages languages) - { - Languages = languages; - } - - /// - /// Gets the languages for which this member should be ignored. - /// - public PolyglotLanguages Languages { get; } -} diff --git a/src/Aspire.Hosting/Polyglot/PolyglotLanguages.cs b/src/Aspire.Hosting/Polyglot/PolyglotLanguages.cs deleted file mode 100644 index 47211946152..00000000000 --- a/src/Aspire.Hosting/Polyglot/PolyglotLanguages.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Aspire.Hosting.Polyglot; - -/// -/// Specifies the set of supported programming languages for polyglot operations. -/// -/// -/// This enumeration supports bitwise combination of its member values. Use the Flags attribute to -/// represent multiple languages simultaneously. -/// -[Flags] -public enum PolyglotLanguages -{ - /// - /// Indicates that no languages are specified. - /// - None = 0, - - /// - /// Indicates TypeScript/JavaScript language support. - /// - TypeScript = 1 << 0, - - /// - /// Indicates Python language support. - /// - Python = 1 << 1, - - /// - /// Indicates all supported languages. - /// - All = TypeScript | Python -} From 1fab1b1817c2f2b8f0f73c2d7a37cee433b38277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 19 Mar 2026 11:38:17 -0700 Subject: [PATCH 18/49] Use home-based CLI cache and randomized socket paths (#15346) * Use home-based CLI cache and socket paths Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Share CLI identifier hashing helpers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add legacy backchannel hash fallback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Align CLI socket and NuGet helpers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update src/Shared/BackchannelConstants.cs Co-authored-by: James Newton-King * Remove unshipped SHA socket fallback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Revert NuGet cache relocation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Simplify CliPathHelper --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: James Newton-King Co-authored-by: Eric Erhardt --- src/Aspire.Cli/Aspire.Cli.csproj | 1 + src/Aspire.Cli/DotNet/DotNetCliRunner.cs | 12 +- src/Aspire.Cli/Program.cs | 4 +- .../Projects/AppHostServerProject.cs | 25 +--- .../Projects/GuestAppHostProject.cs | 6 +- src/Aspire.Cli/Projects/ProjectUpdater.cs | 2 +- src/Aspire.Cli/Utils/AppHostHelper.cs | 10 +- src/Aspire.Cli/Utils/CliPathHelper.cs | 39 +++++ src/Shared/BackchannelConstants.cs | 133 ++++++++++++++---- .../Packaging/PackagingServiceTests.cs | 3 +- .../Utils/AppHostHelperTests.cs | 34 ++++- .../Utils/CliPathHelperTests.cs | 34 +++++ 12 files changed, 222 insertions(+), 81 deletions(-) create mode 100644 src/Aspire.Cli/Utils/CliPathHelper.cs create mode 100644 tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs diff --git a/src/Aspire.Cli/Aspire.Cli.csproj b/src/Aspire.Cli/Aspire.Cli.csproj index adb5afa80a1..7eca03b7b3a 100644 --- a/src/Aspire.Cli/Aspire.Cli.csproj +++ b/src/Aspire.Cli/Aspire.Cli.csproj @@ -58,6 +58,7 @@ + diff --git a/src/Aspire.Cli/DotNet/DotNetCliRunner.cs b/src/Aspire.Cli/DotNet/DotNetCliRunner.cs index 2f88d686563..9ddd56b189c 100644 --- a/src/Aspire.Cli/DotNet/DotNetCliRunner.cs +++ b/src/Aspire.Cli/DotNet/DotNetCliRunner.cs @@ -83,17 +83,7 @@ private string GetMsBuildServerValue() internal static string GetBackchannelSocketPath() { - var homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - var aspireCliPath = Path.Combine(homeDirectory, ".aspire", "cli", "backchannels"); - - if (!Directory.Exists(aspireCliPath)) - { - Directory.CreateDirectory(aspireCliPath); - } - - var uniqueSocketPathSegment = Guid.NewGuid().ToString("N"); - var socketPath = Path.Combine(aspireCliPath, $"cli.sock.{uniqueSocketPathSegment}"); - return socketPath; + return CliPathHelper.CreateSocketPath("cli.sock"); } private async Task ExecuteAsync( diff --git a/src/Aspire.Cli/Program.cs b/src/Aspire.Cli/Program.cs index f5b08d1e98a..98ecc783e6a 100644 --- a/src/Aspire.Cli/Program.cs +++ b/src/Aspire.Cli/Program.cs @@ -53,9 +53,7 @@ public class Program { private static string GetUsersAspirePath() { - var homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - var aspirePath = Path.Combine(homeDirectory, ".aspire"); - return aspirePath; + return CliPathHelper.GetAspireHomeDirectory(); } /// diff --git a/src/Aspire.Cli/Projects/AppHostServerProject.cs b/src/Aspire.Cli/Projects/AppHostServerProject.cs index 7e4a40d38bd..d2c37cc2d5a 100644 --- a/src/Aspire.Cli/Projects/AppHostServerProject.cs +++ b/src/Aspire.Cli/Projects/AppHostServerProject.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Security.Cryptography; -using System.Text; using Aspire.Cli.Bundles; using Aspire.Cli.Configuration; using Aspire.Cli.DotNet; @@ -36,28 +34,7 @@ internal sealed class AppHostServerProjectFactory( { public async Task CreateAsync(string appPath, CancellationToken cancellationToken = default) { - // Normalize the path - var normalizedPath = Path.GetFullPath(appPath); - normalizedPath = new Uri(normalizedPath).LocalPath; - normalizedPath = OperatingSystem.IsWindows() ? normalizedPath.ToLowerInvariant() : normalizedPath; - - // Generate socket path based on app path hash (deterministic for same project) - var pathHash = SHA256.HashData(Encoding.UTF8.GetBytes(normalizedPath)); - var socketName = Convert.ToHexString(pathHash)[..12].ToLowerInvariant() + ".sock"; - - string socketPath; - if (OperatingSystem.IsWindows()) - { - // Windows uses named pipes - socketPath = socketName; - } - else - { - // Unix uses domain sockets - var socketDir = Path.Combine(Path.GetTempPath(), ".aspire", "sockets"); - Directory.CreateDirectory(socketDir); - socketPath = Path.Combine(socketDir, socketName); - } + var socketPath = CliPathHelper.CreateSocketPath("apphost.sock"); // Priority 1: Check for dev mode (ASPIRE_REPO_ROOT or running from Aspire source repo) var repoRoot = AspireRepositoryDetector.DetectRepositoryRoot(appPath); diff --git a/src/Aspire.Cli/Projects/GuestAppHostProject.cs b/src/Aspire.Cli/Projects/GuestAppHostProject.cs index e856ebce8ff..74c16ceda2a 100644 --- a/src/Aspire.Cli/Projects/GuestAppHostProject.cs +++ b/src/Aspire.Cli/Projects/GuestAppHostProject.cs @@ -925,11 +925,7 @@ await GenerateCodeViaRpcAsync( /// private static string GetBackchannelSocketPath() { - var homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - var aspireCliPath = Path.Combine(homeDirectory, ".aspire", "cli", "backchannels"); - Directory.CreateDirectory(aspireCliPath); - var socketName = $"{Guid.NewGuid():N}.sock"; - return Path.Combine(aspireCliPath, socketName); + return CliPathHelper.CreateSocketPath("cli.sock"); } /// diff --git a/src/Aspire.Cli/Projects/ProjectUpdater.cs b/src/Aspire.Cli/Projects/ProjectUpdater.cs index 735d3ddbaff..647011463bd 100644 --- a/src/Aspire.Cli/Projects/ProjectUpdater.cs +++ b/src/Aspire.Cli/Projects/ProjectUpdater.cs @@ -115,7 +115,7 @@ public async Task UpdateProjectAsync(FileInfo projectFile, cancellationToken: cancellationToken); var nugetConfigDirectory = new DirectoryInfo(selectedPathForNewNuGetConfigFile); - await NuGetConfigMerger.CreateOrUpdateAsync(nugetConfigDirectory, channel, AnalyzeAndConfirmNuGetConfigChanges, cancellationToken); + await NuGetConfigMerger.CreateOrUpdateAsync(nugetConfigDirectory, channel, AnalyzeAndConfirmNuGetConfigChanges, cancellationToken: cancellationToken); } interactionService.DisplayEmptyLine(); diff --git a/src/Aspire.Cli/Utils/AppHostHelper.cs b/src/Aspire.Cli/Utils/AppHostHelper.cs index f080a53e909..bcde6f6ae1c 100644 --- a/src/Aspire.Cli/Utils/AppHostHelper.cs +++ b/src/Aspire.Cli/Utils/AppHostHelper.cs @@ -83,7 +83,8 @@ internal static async Task BuildAppHostAsync(IDotNetCliRunner runner, IInte /// Computes the auxiliary backchannel socket path prefix for a given AppHost project file. /// /// - /// Since socket names now include the AppHost's PID (e.g., auxi.sock.{hash}.{pid}), + /// Since socket names now include a randomized instance hash and the AppHost's PID + /// (e.g., auxi.sock.{hash}.{instanceHash}.{pid}), /// the CLI cannot compute the exact socket path. Use this prefix with a glob pattern /// to find matching sockets, or use instead. /// @@ -106,15 +107,16 @@ internal static string[] FindMatchingSockets(string appHostPath, string homeDire /// Extracts the hash portion from an auxiliary socket path. /// /// - /// Works with both old format (auxi.sock.{hash}) and new format (auxi.sock.{hash}.{pid}). + /// Works with old format (auxi.sock.{hash}), previous format (auxi.sock.{hash}.{pid}), + /// and current format (auxi.sock.{hash}.{instanceHash}.{pid}). /// - /// The full socket path (e.g., "/path/to/auxi.sock.b67075ff12d56865.12345"). + /// The full socket path (e.g., "/path/to/auxi.sock.b67075ff12d56865.a1b2c3d4e5f6.12345"). /// The hash portion (e.g., "b67075ff12d56865"), or null if the format is unrecognized. internal static string? ExtractHashFromSocketPath(string socketPath) => BackchannelConstants.ExtractHash(socketPath); /// - /// Extracts the PID from an auxiliary socket path (new format only). + /// Extracts the PID from an auxiliary socket path when one is present. /// /// The full socket path. /// The PID if present and valid, or null for old format sockets. diff --git a/src/Aspire.Cli/Utils/CliPathHelper.cs b/src/Aspire.Cli/Utils/CliPathHelper.cs new file mode 100644 index 00000000000..46f87a397b2 --- /dev/null +++ b/src/Aspire.Cli/Utils/CliPathHelper.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Hosting.Backchannel; + +namespace Aspire.Cli.Utils; + +internal static class CliPathHelper +{ + internal static string GetAspireHomeDirectory() + => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".aspire"); + + /// + /// Creates a randomized CLI-managed socket path. + /// + /// The socket file prefix. + internal static string CreateSocketPath(string socketPrefix) + { + var socketName = $"{socketPrefix}.{BackchannelConstants.CreateRandomIdentifier()}"; + + if (OperatingSystem.IsWindows()) + { + return socketName; + } + + var socketDirectory = GetCliSocketDirectory(); + Directory.CreateDirectory(socketDirectory); + return Path.Combine(socketDirectory, socketName); + } + + private static string GetCliHomeDirectory() + => Path.Combine(GetAspireHomeDirectory(), "cli"); + + private static string GetCliRuntimeDirectory() + => Path.Combine(GetCliHomeDirectory(), "runtime"); + + private static string GetCliSocketDirectory() + => Path.Combine(GetCliRuntimeDirectory(), "sockets"); +} diff --git a/src/Shared/BackchannelConstants.cs b/src/Shared/BackchannelConstants.cs index ea80c64990c..af06aabba44 100644 --- a/src/Shared/BackchannelConstants.cs +++ b/src/Shared/BackchannelConstants.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Globalization; +using System.IO.Hashing; using System.Security.Cryptography; using System.Text; @@ -33,15 +34,19 @@ namespace Aspire.Hosting.Backchannel; /// Socket Naming Format /// /// -/// New format: auxi.sock.{hash}.{pid} +/// New format: auxi.sock.{appHostHash}.{instanceHash}.{pid} /// /// /// auxi.sock - Prefix (not "aux" because that's reserved on Windows) -/// {hash} - SHA256(AppHost project path)[0:16] - identifies the AppHost project +/// {appHostHash} - xxHash(AppHost project path)[0:16] - identifies the AppHost project +/// {instanceHash} - random hex identifier[0:12] - makes each socket name non-deterministic /// {pid} - Process ID of the AppHost - identifies the specific instance /// /// -/// Old format (for backward compatibility): auxi.sock.{hash} +/// Previous format (for backward compatibility): auxi.sock.{appHostHash}.{pid} +/// +/// +/// Old format (for backward compatibility): auxi.sock.{appHostHash} /// /// /// Why PID in the Filename? @@ -72,16 +77,30 @@ internal static class BackchannelConstants public const string SocketPrefix = "auxi.sock"; /// - /// Number of hex characters to use from the SHA256 hash. + /// Number of hex characters to use from the stable xxHash-based AppHost identifier. /// /// /// Using 16 chars (64 bits) balances uniqueness against path length constraints. /// Unix socket paths are limited to ~104 characters on most systems. - /// Full path example: ~/.aspire/cli/backchannels/auxi.sock.bc43b855b6848166.46730 - /// = ~65 characters, well under the limit. + /// Full path example: ~/.aspire/cli/backchannels/auxi.sock.bc43b855b6848166.a1b2c3d4e5f6.46730 + /// = ~78 characters, well under the limit. /// public const int HashLength = 16; + /// + /// Number of hex characters to use for compact local identifiers. + /// + /// + /// Using 12 chars (48 bits) keeps socket and package cache paths short while still providing + /// enough variation for local file names that are not part of a security boundary. + /// + public const int CompactIdentifierLength = 12; + + /// + /// Number of hex characters to use from the randomized instance identifier. + /// + public const int InstanceHashLength = CompactIdentifierLength; + /// /// Gets the backchannels directory path for the given home directory. /// @@ -103,16 +122,15 @@ public static string GetBackchannelsDirectory(string homeDirectory) /// A 16-character lowercase hex string. public static string ComputeHash(string appHostPath) { - var hashBytes = SHA256.HashData(Encoding.UTF8.GetBytes(appHostPath)); - return Convert.ToHexString(hashBytes)[..HashLength].ToLowerInvariant(); + return ComputeStableIdentifier(appHostPath, HashLength); } /// /// Computes the full socket path for an AppHost instance. /// /// - /// Called by AppHost when creating the socket. Includes the PID to ensure - /// uniqueness across multiple instances of the same AppHost. + /// Called by AppHost when creating the socket. Includes a randomized instance hash and the PID + /// to ensure uniqueness across multiple instances of the same AppHost. /// /// The full path to the AppHost project file. /// The user's home directory. @@ -122,7 +140,8 @@ public static string ComputeSocketPath(string appHostPath, string homeDirectory, { var dir = GetBackchannelsDirectory(homeDirectory); var hash = ComputeHash(appHostPath); - return Path.Combine(dir, $"{SocketPrefix}.{hash}.{processId}"); + var instanceHash = CreateRandomIdentifier(InstanceHashLength); + return Path.Combine(dir, $"{SocketPrefix}.{hash}.{instanceHash}.{processId}"); } /// @@ -147,7 +166,8 @@ public static string ComputeSocketPrefix(string appHostPath, string homeDirector /// /// /// Returns all socket files for an AppHost, regardless of PID. This includes - /// both old format (auxi.sock.{hash}) and new format (auxi.sock.{hash}.{pid}). + /// old format (auxi.sock.{hash}), previous format (auxi.sock.{hash}.{pid}), + /// and current format (auxi.sock.{hash}.{instanceHash}.{pid}). /// /// The full path to the AppHost project file. /// The user's home directory. @@ -163,13 +183,15 @@ public static string[] FindMatchingSockets(string appHostPath, string homeDirect return []; } - // Match both old format (auxi.sock.{hash}) and new format (auxi.sock.{hash}.{pid}) + // Match old format (auxi.sock.{hash}), previous format (auxi.sock.{hash}.{pid}), + // and current format (auxi.sock.{hash}.{instanceHash}.{pid}) // Use pattern with "*" to match optional PID suffix var allMatches = Directory.GetFiles(dir, prefixFileName + "*"); - // Filter to only include exact match (old format) or .{pid} suffix (new format) - // This avoids matching auxi.sock.{hash}abc (different hash that starts with same chars) - // and also avoids matching files like auxi.sock.{hash}.12345.bak + // Filter to only include exact match (old format), .{pid} suffix (previous format), + // or .{instanceHash}.{pid} suffix (current format). This avoids matching + // auxi.sock.{hash}abc (different hash that starts with same chars) and files + // like auxi.sock.{hash}.12345.bak. return allMatches.Where(f => { var fileName = Path.GetFileName(f); @@ -177,12 +199,24 @@ public static string[] FindMatchingSockets(string appHostPath, string homeDirect { return true; // Old format: exact match } - if (fileName.StartsWith(prefixFileName + ".", StringComparison.Ordinal) && - int.TryParse(fileName.AsSpan(prefixFileName.Length + 1), NumberStyles.None, CultureInfo.InvariantCulture, out _)) + + if (!fileName.StartsWith(prefixFileName + ".", StringComparison.Ordinal)) { - return true; // New format: prefix followed by dot and integer PID + return false; } - return false; + + var suffix = fileName[(prefixFileName.Length + 1)..]; + var segments = suffix.Split('.'); + + if (segments.Length == 1 && + int.TryParse(segments[0], NumberStyles.None, CultureInfo.InvariantCulture, out _)) + { + return true; // Previous format: prefix followed by integer PID + } + + return segments.Length == 2 && + IsHex(segments[0]) && + int.TryParse(segments[1], NumberStyles.None, CultureInfo.InvariantCulture, out _); }).ToArray(); } @@ -190,7 +224,8 @@ public static string[] FindMatchingSockets(string appHostPath, string homeDirect /// Extracts the hash from a socket filename. /// /// - /// Works with both old format (auxi.sock.{hash}) and new format (auxi.sock.{hash}.{pid}). + /// Works with old format (auxi.sock.{hash}), previous format (auxi.sock.{hash}.{pid}), + /// and current format (auxi.sock.{hash}.{instanceHash}.{pid}). /// /// The full socket path or filename. /// The hash portion, or null if the format is unrecognized. @@ -198,12 +233,13 @@ public static string[] FindMatchingSockets(string appHostPath, string homeDirect { var fileName = Path.GetFileName(socketPath); - // Handle new format: auxi.sock.{hash}.{pid} + // Handle current format: auxi.sock.{hash}.{instanceHash}.{pid} + // Handle previous format: auxi.sock.{hash}.{pid} // Handle old format: auxi.sock.{hash} if (fileName.StartsWith($"{SocketPrefix}.", StringComparison.Ordinal)) { var afterPrefix = fileName[($"{SocketPrefix}.".Length)..]; - // If there's another dot, it's new format - return just the hash part + // If there's another dot, it's a multi-segment format - return just the AppHost hash part var dotIndex = afterPrefix.IndexOf('.'); return dotIndex > 0 ? afterPrefix[..dotIndex] : afterPrefix; } @@ -220,7 +256,7 @@ public static string[] FindMatchingSockets(string appHostPath, string homeDirect } /// - /// Extracts the PID from a socket filename (new format only). + /// Extracts the PID from a socket filename when one is present. /// /// The full socket path or filename. /// The PID if present and valid, or null for old format sockets. @@ -273,7 +309,8 @@ public static bool ProcessExists(int pid) /// support PID-based orphan detection. /// /// - /// Limitation: This method only cleans up new format sockets (auxi.sock.{hash}.{pid}) + /// Limitation: This method only cleans up sockets that include a PID + /// (auxi.sock.{hash}.{pid} or auxi.sock.{hash}.{instanceHash}.{pid}) /// because old format sockets (auxi.sock.{hash}) don't have a PID for orphan detection. /// Old format sockets are cleaned up via connection-based detection in the CLI. /// @@ -291,7 +328,7 @@ public static int CleanupOrphanedSockets(string backchannelsDirectory, string ha return deleted; } - // Find all sockets for this hash (both old and new format) + // Find all sockets for this hash across all supported formats. var pattern = $"{SocketPrefix}.{hash}*"; foreach (var socketPath in Directory.GetFiles(backchannelsDirectory, pattern)) { @@ -317,4 +354,48 @@ public static int CleanupOrphanedSockets(string backchannelsDirectory, string ha return deleted; } + + /// + /// Computes a compact stable identifier from a string value. + /// + /// + /// Uses XxHash3 because these identifiers are only used for local naming and lookup. They do not + /// protect secrets or cross a trust boundary, so a fast non-cryptographic hash is preferable to SHA-2. + /// + /// The string value to hash. + /// The number of lowercase hex characters to return. + /// A lowercase hex identifier truncated to characters. + public static string ComputeStableIdentifier(string value, int length = CompactIdentifierLength) + { + ArgumentException.ThrowIfNullOrEmpty(value); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(length); + var xxHash = new XxHash3(); + xxHash.Append(Encoding.UTF8.GetBytes(value)); + + return ToLowerHexIdentifier(xxHash.GetCurrentHash(), length); + } + + /// + /// Creates a compact randomized identifier. + /// + /// The number of lowercase hex characters to return. + /// A lowercase hex identifier truncated to characters. + public static string CreateRandomIdentifier(int length = CompactIdentifierLength) + { + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(length); + + Span randomBytes = stackalloc byte[(length + 1) / 2]; + RandomNumberGenerator.Fill(randomBytes); + + return ToLowerHexIdentifier(randomBytes, length); + } + + private static bool IsHex(string value) + => !string.IsNullOrEmpty(value) && value.All(static c => char.IsAsciiHexDigit(c)); + + private static string ToLowerHexIdentifier(ReadOnlySpan bytes, int length) + { + var hex = Convert.ToHexString(bytes).ToLowerInvariant(); + return hex[..Math.Min(length, hex.Length)]; + } } diff --git a/tests/Aspire.Cli.Tests/Packaging/PackagingServiceTests.cs b/tests/Aspire.Cli.Tests/Packaging/PackagingServiceTests.cs index 51ce56b6907..7cf4720ef09 100644 --- a/tests/Aspire.Cli.Tests/Packaging/PackagingServiceTests.cs +++ b/tests/Aspire.Cli.Tests/Packaging/PackagingServiceTests.cs @@ -382,7 +382,8 @@ public async Task NuGetConfigMerger_WhenChannelRequiresGlobalPackagesFolder_Adds var globalPackagesFolderAdd = configSection.Elements("add") .FirstOrDefault(add => string.Equals((string?)add.Attribute("key"), "globalPackagesFolder", StringComparison.OrdinalIgnoreCase)); Assert.NotNull(globalPackagesFolderAdd); - Assert.Equal(".nugetpackages", (string?)globalPackagesFolderAdd.Attribute("value")); + var actualGlobalPackagesFolder = (string?)globalPackagesFolderAdd.Attribute("value"); + Assert.Equal(".nugetpackages", actualGlobalPackagesFolder); } [Fact] diff --git a/tests/Aspire.Cli.Tests/Utils/AppHostHelperTests.cs b/tests/Aspire.Cli.Tests/Utils/AppHostHelperTests.cs index 23f862445ed..87c2fcc5dca 100644 --- a/tests/Aspire.Cli.Tests/Utils/AppHostHelperTests.cs +++ b/tests/Aspire.Cli.Tests/Utils/AppHostHelperTests.cs @@ -97,14 +97,25 @@ public void ComputeAuxiliarySocketPrefix_HashIs16Characters() [Fact] public void ExtractHashFromSocketPath_ExtractsHashFromNewFormat() { - // New format: auxi.sock.{hash}.{pid} - var socketPath = "/home/user/.aspire/cli/backchannels/auxi.sock.abc123def4567890.12345"; + // Current format: auxi.sock.{hash}.{instanceHash}.{pid} + var socketPath = "/home/user/.aspire/cli/backchannels/auxi.sock.abc123def4567890.a1b2c3d4e5f6.12345"; var hash = AppHostHelper.ExtractHashFromSocketPath(socketPath); Assert.Equal("abc123def4567890", hash); } + [Fact] + public void ExtractHashFromSocketPath_ExtractsHashFromPreviousFormat() + { + // Previous format: auxi.sock.{hash}.{pid} + var socketPath = "/home/user/.aspire/cli/backchannels/auxi.sock.abc123def4567890.12345"; + + var hash = AppHostHelper.ExtractHashFromSocketPath(socketPath); + + Assert.Equal("abc123def4567890", hash); + } + [Fact] public void ExtractHashFromSocketPath_ExtractsHashFromOldFormat() { @@ -140,14 +151,25 @@ public void ExtractHashFromSocketPath_ReturnsNullForUnrecognizedFormat() [Fact] public void ExtractPidFromSocketPath_ExtractsPidFromNewFormat() { - // New format: auxi.sock.{hash}.{pid} - var socketPath = "/home/user/.aspire/cli/backchannels/auxi.sock.abc123def4567890.12345"; + // Current format: auxi.sock.{hash}.{instanceHash}.{pid} + var socketPath = "/home/user/.aspire/cli/backchannels/auxi.sock.abc123def4567890.a1b2c3d4e5f6.12345"; var pid = AppHostHelper.ExtractPidFromSocketPath(socketPath); Assert.Equal(12345, pid); } + [Fact] + public void ExtractPidFromSocketPath_ExtractsPidFromPreviousFormat() + { + // Previous format: auxi.sock.{hash}.{pid} + var socketPath = "/home/user/.aspire/cli/backchannels/auxi.sock.abc123def4567890.12345"; + + var pid = AppHostHelper.ExtractPidFromSocketPath(socketPath); + + Assert.Equal(12345, pid); + } + [Fact] public void ExtractPidFromSocketPath_ReturnsNullForOldFormat() { @@ -215,8 +237,8 @@ public void FindMatchingSockets_FindsMatchingSocketFiles() var prefix = AppHostHelper.ComputeAuxiliarySocketPrefix(appHostPath, workspace.WorkspaceRoot.FullName); var hash = Path.GetFileName(prefix)["auxi.sock.".Length..]; - // Create matching socket files (new format with PID) - var socket1 = Path.Combine(backchannelsDir, $"auxi.sock.{hash}.12345"); + // Create matching socket files in both current and previous formats. + var socket1 = Path.Combine(backchannelsDir, $"auxi.sock.{hash}.a1b2c3d4e5f6.12345"); var socket2 = Path.Combine(backchannelsDir, $"auxi.sock.{hash}.67890"); File.WriteAllText(socket1, ""); File.WriteAllText(socket2, ""); diff --git a/tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs b/tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs new file mode 100644 index 00000000000..5f31d7fa973 --- /dev/null +++ b/tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Cli.Utils; + +namespace Aspire.Cli.Tests.Utils; + +public class CliPathHelperTests(ITestOutputHelper outputHelper) +{ + [Fact] + public void CreateSocketPath_UsesRandomizedIdentifier() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var socketPath1 = CliPathHelper.CreateSocketPath("apphost.sock"); + var socketPath2 = CliPathHelper.CreateSocketPath("apphost.sock"); + + Assert.NotEqual(socketPath1, socketPath2); + + if (OperatingSystem.IsWindows()) + { + Assert.Matches("^apphost\\.sock\\.[a-f0-9]{12}$", socketPath1); + Assert.Matches("^apphost\\.sock\\.[a-f0-9]{12}$", socketPath2); + } + else + { + var expectedDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".aspire", "cli", "runtime", "sockets"); + Assert.Equal(expectedDirectory, Path.GetDirectoryName(socketPath1)); + Assert.Equal(expectedDirectory, Path.GetDirectoryName(socketPath2)); + Assert.Matches("^apphost\\.sock\\.[a-f0-9]{12}$", Path.GetFileName(socketPath1)); + Assert.Matches("^apphost\\.sock\\.[a-f0-9]{12}$", Path.GetFileName(socketPath2)); + } + } +} From 2a24bf9554ba8b9896ac811b9d7efd921b0c9d8e Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 20 Mar 2026 02:40:39 +0800 Subject: [PATCH 19/49] [release/13.2] Fix dashboard GitHub Copilot integration (#15381) * Fix dashboard GHCP * Add comment * Fix dashboard tests for non-nullable resourceName parameter * Apply suggestions from code review Co-authored-by: Eric Erhardt --------- Co-authored-by: Eric Erhardt --- Directory.Packages.props | 2 +- eng/Versions.props | 2 +- .../Model/Assistant/AssistantChatDataContext.cs | 6 ++++-- .../Model/Assistant/AssistantChatViewModel.cs | 2 +- .../Model/AIAssistant/AssistantChatDataContextTests.cs | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 06d000e49fc..8ee92baad8a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -118,7 +118,7 @@ - + diff --git a/eng/Versions.props b/eng/Versions.props index e83d5c79f44..ffb5ea9ce7f 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -41,7 +41,7 @@ 11.0.0-beta.25610.3 10.2.0 - 10.1.0-preview.1.25608.1 + 10.2.0-preview.1.26063.2 10.0.0-preview.1.25559.3 10.2.0 10.2.0 diff --git a/src/Aspire.Dashboard/Model/Assistant/AssistantChatDataContext.cs b/src/Aspire.Dashboard/Model/Assistant/AssistantChatDataContext.cs index 8cebb29ba0f..1437a6d202a 100644 --- a/src/Aspire.Dashboard/Model/Assistant/AssistantChatDataContext.cs +++ b/src/Aspire.Dashboard/Model/Assistant/AssistantChatDataContext.cs @@ -102,10 +102,11 @@ public async Task GetTraceAsync( return SharedAIHelpers.GetTraceJson(spans, r => OtlpHelpers.GetResourceName(r, resources), AIHelpers.GetDashboardUrl(_dashboardOptions.CurrentValue)); } + // resourceName is provided as a non-nullable string to prevent the JSON schema from including an array. An array breaks VS integration. [Description("Get structured logs for resources.")] public async Task GetStructuredLogsAsync( [Description("The resource name. This limits logs returned to the specified resource. If no resource name is specified then structured logs for all resources are returned.")] - string? resourceName = null, + string resourceName, CancellationToken cancellationToken = default) { // TODO: The resourceName might be a name that resolves to multiple replicas, e.g. catalogservice has two replicas. @@ -147,10 +148,11 @@ public async Task GetStructuredLogsAsync( return response; } + // resourceName is provided as a non-nullable string to prevent the JSON schema from including an array. An array breaks VS integration. [Description("Get distributed traces for resources. A distributed trace is used to track operations. A distributed trace can span multiple resources across a distributed system. Includes a list of distributed traces with their IDs, resources in the trace, duration and whether an error occurred in the trace.")] public async Task GetTracesAsync( [Description("The resource name. This limits traces returned to the specified resource. If no resource name is specified then distributed traces for all resources are returned.")] - string? resourceName = null, + string resourceName, CancellationToken cancellationToken = default) { // TODO: The resourceName might be a name that resolves to multiple replicas, e.g. catalogservice has two replicas. diff --git a/src/Aspire.Dashboard/Model/Assistant/AssistantChatViewModel.cs b/src/Aspire.Dashboard/Model/Assistant/AssistantChatViewModel.cs index 21549f075b2..546ed86c59c 100644 --- a/src/Aspire.Dashboard/Model/Assistant/AssistantChatViewModel.cs +++ b/src/Aspire.Dashboard/Model/Assistant/AssistantChatViewModel.cs @@ -95,7 +95,7 @@ public sealed class AssistantChatViewModel : IDisposable private const int MaximumResponseLength = 1024 * 1024 * 10; // Small, cheap, fast model for follow up questions. private const string FollowUpQuestionsModel = "gpt-4o-mini"; - private static readonly string[] s_defaultModels = ["gpt-4.1", "gpt-4o"]; + private static readonly string[] s_defaultModels = ["gpt-5.4", "gpt-4.1", "gpt-4o"]; // Older models that VS Code returns as available models. Don't show them in the model selector. // There are better, cheaper alternatives that should always be used. private static readonly string[] s_oldModels = ["gpt-4", "gpt-4-turbo", "gpt-3.5-turbo"]; diff --git a/tests/Aspire.Dashboard.Tests/Model/AIAssistant/AssistantChatDataContextTests.cs b/tests/Aspire.Dashboard.Tests/Model/AIAssistant/AssistantChatDataContextTests.cs index bf57c341dac..22ef2cf8f1c 100644 --- a/tests/Aspire.Dashboard.Tests/Model/AIAssistant/AssistantChatDataContextTests.cs +++ b/tests/Aspire.Dashboard.Tests/Model/AIAssistant/AssistantChatDataContextTests.cs @@ -47,7 +47,7 @@ public async Task GetStructuredLogs_ExceedTokenLimit_ReturnMostRecentItems() var dataContext = CreateAssistantChatDataContext(telemetryRepository: repository); // Act - var result = await dataContext.GetStructuredLogsAsync(resourceName: null, CancellationToken.None); + var result = await dataContext.GetStructuredLogsAsync(resourceName: null!, CancellationToken.None); // Assert for (var i = 6; i < 20; i++) @@ -81,7 +81,7 @@ public async Task GetTraces_ExceedTokenLimit_ReturnMostRecentItems() var dataContext = CreateAssistantChatDataContext(telemetryRepository: repository); // Act - var result = await dataContext.GetTracesAsync(resourceName: null, CancellationToken.None); + var result = await dataContext.GetTracesAsync(resourceName: null!, CancellationToken.None); // Assert for (var i = 7; i < 20; i++) From 6e586690197ed4f18450302375fc24643574bda4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 19 Mar 2026 12:09:48 -0700 Subject: [PATCH 20/49] Mark code generation packages experimental (#15371) * Mark code generation packages as preview Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Mark code generation packages experimental Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Internalize code generation implementations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../AssemblyInfo.cs | 6 ++ .../AtsGoCodeGenerator.cs | 2 +- .../GoLanguageSupport.cs | 2 +- .../AssemblyInfo.cs | 6 ++ .../AtsJavaCodeGenerator.cs | 2 +- .../JavaLanguageSupport.cs | 2 +- .../AssemblyInfo.cs | 6 ++ .../AtsPythonCodeGenerator.cs | 2 +- .../PythonLanguageSupport.cs | 2 +- .../AssemblyInfo.cs | 6 ++ .../AtsRustCodeGenerator.cs | 2 +- .../RustLanguageSupport.cs | 2 +- .../AssemblyInfo.cs | 6 ++ .../AtsTypeScriptCodeGenerator.cs | 2 +- .../TypeScriptLanguageSupport.cs | 2 +- .../Aspire.Hosting.RemoteHost.Tests.csproj | 5 ++ .../CodeGenerationResolverTests.cs | 60 +++++++++++++++++++ 17 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 src/Aspire.Hosting.CodeGeneration.Go/AssemblyInfo.cs create mode 100644 src/Aspire.Hosting.CodeGeneration.Java/AssemblyInfo.cs create mode 100644 src/Aspire.Hosting.CodeGeneration.Python/AssemblyInfo.cs create mode 100644 src/Aspire.Hosting.CodeGeneration.Rust/AssemblyInfo.cs create mode 100644 src/Aspire.Hosting.CodeGeneration.TypeScript/AssemblyInfo.cs create mode 100644 tests/Aspire.Hosting.RemoteHost.Tests/CodeGenerationResolverTests.cs diff --git a/src/Aspire.Hosting.CodeGeneration.Go/AssemblyInfo.cs b/src/Aspire.Hosting.CodeGeneration.Go/AssemblyInfo.cs new file mode 100644 index 00000000000..79236a7dbec --- /dev/null +++ b/src/Aspire.Hosting.CodeGeneration.Go/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; + +[assembly: Experimental("ASPIREATS001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] diff --git a/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs index 780aee66108..29ea4501cc6 100644 --- a/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs @@ -12,7 +12,7 @@ namespace Aspire.Hosting.CodeGeneration.Go; /// Generates a Go SDK using the ATS (Aspire Type System) capability-based API. /// Produces wrapper structs that proxy capabilities via JSON-RPC. /// -public sealed class AtsGoCodeGenerator : ICodeGenerator +internal sealed class AtsGoCodeGenerator : ICodeGenerator { private static readonly HashSet s_goKeywords = new(StringComparer.Ordinal) { diff --git a/src/Aspire.Hosting.CodeGeneration.Go/GoLanguageSupport.cs b/src/Aspire.Hosting.CodeGeneration.Go/GoLanguageSupport.cs index 99b21fdce31..2b6b637ee81 100644 --- a/src/Aspire.Hosting.CodeGeneration.Go/GoLanguageSupport.cs +++ b/src/Aspire.Hosting.CodeGeneration.Go/GoLanguageSupport.cs @@ -9,7 +9,7 @@ namespace Aspire.Hosting.CodeGeneration.Go; /// Provides language support for Go AppHosts. /// Implements scaffolding, detection, and runtime configuration. /// -public sealed class GoLanguageSupport : ILanguageSupport +internal sealed class GoLanguageSupport : ILanguageSupport { /// /// The language/runtime identifier for Go. diff --git a/src/Aspire.Hosting.CodeGeneration.Java/AssemblyInfo.cs b/src/Aspire.Hosting.CodeGeneration.Java/AssemblyInfo.cs new file mode 100644 index 00000000000..79236a7dbec --- /dev/null +++ b/src/Aspire.Hosting.CodeGeneration.Java/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; + +[assembly: Experimental("ASPIREATS001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] diff --git a/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs index 5663376668a..1a96c4760e2 100644 --- a/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs @@ -12,7 +12,7 @@ namespace Aspire.Hosting.CodeGeneration.Java; /// Generates a Java SDK using the ATS (Aspire Type System) capability-based API. /// Produces wrapper classes that proxy capabilities via JSON-RPC. /// -public sealed class AtsJavaCodeGenerator : ICodeGenerator +internal sealed class AtsJavaCodeGenerator : ICodeGenerator { private static readonly HashSet s_javaKeywords = new(StringComparer.Ordinal) { diff --git a/src/Aspire.Hosting.CodeGeneration.Java/JavaLanguageSupport.cs b/src/Aspire.Hosting.CodeGeneration.Java/JavaLanguageSupport.cs index d050f07fc46..2db8a48fc01 100644 --- a/src/Aspire.Hosting.CodeGeneration.Java/JavaLanguageSupport.cs +++ b/src/Aspire.Hosting.CodeGeneration.Java/JavaLanguageSupport.cs @@ -9,7 +9,7 @@ namespace Aspire.Hosting.CodeGeneration.Java; /// Provides language support for Java AppHosts. /// Implements scaffolding, detection, and runtime configuration. /// -public sealed class JavaLanguageSupport : ILanguageSupport +internal sealed class JavaLanguageSupport : ILanguageSupport { /// /// The language/runtime identifier for Java. diff --git a/src/Aspire.Hosting.CodeGeneration.Python/AssemblyInfo.cs b/src/Aspire.Hosting.CodeGeneration.Python/AssemblyInfo.cs new file mode 100644 index 00000000000..79236a7dbec --- /dev/null +++ b/src/Aspire.Hosting.CodeGeneration.Python/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; + +[assembly: Experimental("ASPIREATS001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] diff --git a/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs index d2b8d94b043..173a3be126d 100644 --- a/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs @@ -13,7 +13,7 @@ namespace Aspire.Hosting.CodeGeneration.Python; /// Generates a Python SDK using the ATS (Aspire Type System) capability-based API. /// Produces wrapper classes that proxy capabilities via JSON-RPC. /// -public sealed class AtsPythonCodeGenerator : ICodeGenerator +internal sealed class AtsPythonCodeGenerator : ICodeGenerator { private static readonly HashSet s_pythonKeywords = new(StringComparer.OrdinalIgnoreCase) { diff --git a/src/Aspire.Hosting.CodeGeneration.Python/PythonLanguageSupport.cs b/src/Aspire.Hosting.CodeGeneration.Python/PythonLanguageSupport.cs index f9f5ccea604..2b39ca57771 100644 --- a/src/Aspire.Hosting.CodeGeneration.Python/PythonLanguageSupport.cs +++ b/src/Aspire.Hosting.CodeGeneration.Python/PythonLanguageSupport.cs @@ -10,7 +10,7 @@ namespace Aspire.Hosting.CodeGeneration.Python; /// Provides language support for Python AppHosts. /// Implements scaffolding, detection, and runtime configuration. /// -public sealed class PythonLanguageSupport : ILanguageSupport +internal sealed class PythonLanguageSupport : ILanguageSupport { /// /// The language/runtime identifier for Python. diff --git a/src/Aspire.Hosting.CodeGeneration.Rust/AssemblyInfo.cs b/src/Aspire.Hosting.CodeGeneration.Rust/AssemblyInfo.cs new file mode 100644 index 00000000000..79236a7dbec --- /dev/null +++ b/src/Aspire.Hosting.CodeGeneration.Rust/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; + +[assembly: Experimental("ASPIREATS001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] diff --git a/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs index ccefa5c38c1..33ea6c05f6e 100644 --- a/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs @@ -13,7 +13,7 @@ namespace Aspire.Hosting.CodeGeneration.Rust; /// Generates a Rust SDK using the ATS (Aspire Type System) capability-based API. /// Produces wrapper structs that proxy capabilities via JSON-RPC. /// -public sealed class AtsRustCodeGenerator : ICodeGenerator +internal sealed class AtsRustCodeGenerator : ICodeGenerator { private static readonly HashSet s_rustKeywords = new(StringComparer.Ordinal) { diff --git a/src/Aspire.Hosting.CodeGeneration.Rust/RustLanguageSupport.cs b/src/Aspire.Hosting.CodeGeneration.Rust/RustLanguageSupport.cs index 69455ca1f5b..a8278e4f70e 100644 --- a/src/Aspire.Hosting.CodeGeneration.Rust/RustLanguageSupport.cs +++ b/src/Aspire.Hosting.CodeGeneration.Rust/RustLanguageSupport.cs @@ -9,7 +9,7 @@ namespace Aspire.Hosting.CodeGeneration.Rust; /// Provides language support for Rust AppHosts. /// Implements scaffolding, detection, and runtime configuration. /// -public sealed class RustLanguageSupport : ILanguageSupport +internal sealed class RustLanguageSupport : ILanguageSupport { /// /// The language/runtime identifier for Rust. diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/AssemblyInfo.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/AssemblyInfo.cs new file mode 100644 index 00000000000..79236a7dbec --- /dev/null +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; + +[assembly: Experimental("ASPIREATS001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs index 8d2b152a7e7..66d6da9ed58 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs @@ -96,7 +96,7 @@ internal sealed class BuilderModel /// /// /// -public sealed class AtsTypeScriptCodeGenerator : ICodeGenerator +internal sealed class AtsTypeScriptCodeGenerator : ICodeGenerator { private TextWriter _writer = null!; diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs index d237885feeb..7858548d2d3 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs @@ -9,7 +9,7 @@ namespace Aspire.Hosting.CodeGeneration.TypeScript; /// Provides language support for TypeScript AppHosts. /// Implements scaffolding, detection, and runtime configuration. /// -public sealed class TypeScriptLanguageSupport : ILanguageSupport +internal sealed class TypeScriptLanguageSupport : ILanguageSupport { /// /// The language/runtime identifier for TypeScript with Node.js. diff --git a/tests/Aspire.Hosting.RemoteHost.Tests/Aspire.Hosting.RemoteHost.Tests.csproj b/tests/Aspire.Hosting.RemoteHost.Tests/Aspire.Hosting.RemoteHost.Tests.csproj index 4e7ba3f8a1a..6f3d4eac806 100644 --- a/tests/Aspire.Hosting.RemoteHost.Tests/Aspire.Hosting.RemoteHost.Tests.csproj +++ b/tests/Aspire.Hosting.RemoteHost.Tests/Aspire.Hosting.RemoteHost.Tests.csproj @@ -6,6 +6,11 @@ + + + + + diff --git a/tests/Aspire.Hosting.RemoteHost.Tests/CodeGenerationResolverTests.cs b/tests/Aspire.Hosting.RemoteHost.Tests/CodeGenerationResolverTests.cs new file mode 100644 index 00000000000..adc98f38d47 --- /dev/null +++ b/tests/Aspire.Hosting.RemoteHost.Tests/CodeGenerationResolverTests.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Hosting.RemoteHost.CodeGeneration; +using Aspire.Hosting.RemoteHost.Language; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; +using Xunit; + +namespace Aspire.Hosting.RemoteHost.Tests; + +public class CodeGenerationResolverTests +{ + [Fact] + public void CodeGeneratorResolver_DiscoversInternalCodeGenerators() + { + using var serviceProvider = CreateServiceProvider(); + var assemblyLoader = CreateAssemblyLoader(); + var resolver = new CodeGeneratorResolver(serviceProvider, assemblyLoader, NullLogger.Instance); + + Assert.NotNull(resolver.GetCodeGenerator("Go")); + Assert.NotNull(resolver.GetCodeGenerator("Java")); + Assert.NotNull(resolver.GetCodeGenerator("Python")); + Assert.NotNull(resolver.GetCodeGenerator("Rust")); + Assert.NotNull(resolver.GetCodeGenerator("TypeScript")); + } + + [Fact] + public void LanguageSupportResolver_DiscoversInternalLanguageSupports() + { + using var serviceProvider = CreateServiceProvider(); + var assemblyLoader = CreateAssemblyLoader(); + var resolver = new LanguageSupportResolver(serviceProvider, assemblyLoader, NullLogger.Instance); + + Assert.NotNull(resolver.GetLanguageSupport("go")); + Assert.NotNull(resolver.GetLanguageSupport("java")); + Assert.NotNull(resolver.GetLanguageSupport("python")); + Assert.NotNull(resolver.GetLanguageSupport("rust")); + Assert.NotNull(resolver.GetLanguageSupport("typescript/nodejs")); + } + + private static ServiceProvider CreateServiceProvider() => new ServiceCollection().BuildServiceProvider(); + + private static AssemblyLoader CreateAssemblyLoader() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["AtsAssemblies:0"] = "Aspire.Hosting.CodeGeneration.Go", + ["AtsAssemblies:1"] = "Aspire.Hosting.CodeGeneration.Java", + ["AtsAssemblies:2"] = "Aspire.Hosting.CodeGeneration.Python", + ["AtsAssemblies:3"] = "Aspire.Hosting.CodeGeneration.Rust", + ["AtsAssemblies:4"] = "Aspire.Hosting.CodeGeneration.TypeScript", + }) + .Build(); + + return new AssemblyLoader(configuration, NullLogger.Instance); + } +} From a79dde431110958cde8210dbc949ed27ec50fa3d Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 19 Mar 2026 19:05:50 -0400 Subject: [PATCH 21/49] Include restored packages in `aspire cache clear` (#15387) * Include packages/restore in aspire cache clear The cache clear command was not clearing ~/.aspire/packages/ which contains restored NuGet packages for apphost server sessions. When the CLI binary is updated but the cached DLLs have the same version string, stale packages persist and cause failures (e.g. missing auth handshake in transport.ts). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review feedback: extract helper, use EnumerateFiles, add tests - Extract ClearDirectoryContents helper to deduplicate directory-clearing logic - Use EnumerateFiles with IgnoreInaccessible instead of GetFiles to handle inaccessible paths gracefully during enumeration - Add tests for packages directory clearing, skip predicate, null/nonexistent directory handling Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix test: use WorkspaceRoot instead of WorkingDirectory Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Aspire.Cli/CliExecutionContext.cs | 7 +- src/Aspire.Cli/Commands/CacheCommand.cs | 157 +++++++----------- src/Aspire.Cli/Program.cs | 10 +- .../Commands/CacheCommandTests.cs | 116 +++++++++++++ tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs | 4 +- 5 files changed, 190 insertions(+), 104 deletions(-) diff --git a/src/Aspire.Cli/CliExecutionContext.cs b/src/Aspire.Cli/CliExecutionContext.cs index 062c2b6c35c..59c31c93a89 100644 --- a/src/Aspire.Cli/CliExecutionContext.cs +++ b/src/Aspire.Cli/CliExecutionContext.cs @@ -5,13 +5,18 @@ namespace Aspire.Cli; -internal sealed class CliExecutionContext(DirectoryInfo workingDirectory, DirectoryInfo hivesDirectory, DirectoryInfo cacheDirectory, DirectoryInfo sdksDirectory, DirectoryInfo logsDirectory, string logFilePath, bool debugMode = false, IReadOnlyDictionary? environmentVariables = null, DirectoryInfo? homeDirectory = null) +internal sealed class CliExecutionContext(DirectoryInfo workingDirectory, DirectoryInfo hivesDirectory, DirectoryInfo cacheDirectory, DirectoryInfo sdksDirectory, DirectoryInfo logsDirectory, string logFilePath, bool debugMode = false, IReadOnlyDictionary? environmentVariables = null, DirectoryInfo? homeDirectory = null, DirectoryInfo? packagesDirectory = null) { public DirectoryInfo WorkingDirectory { get; } = workingDirectory; public DirectoryInfo HivesDirectory { get; } = hivesDirectory; public DirectoryInfo CacheDirectory { get; } = cacheDirectory; public DirectoryInfo SdksDirectory { get; } = sdksDirectory; + /// + /// Gets the directory where restored NuGet packages are cached for apphost server sessions. + /// + public DirectoryInfo? PackagesDirectory { get; } = packagesDirectory; + /// /// Gets the directory where CLI log files are stored. /// Used by cache clear command to clean up old log files. diff --git a/src/Aspire.Cli/Commands/CacheCommand.cs b/src/Aspire.Cli/Commands/CacheCommand.cs index 860d29e1332..1fb343610bf 100644 --- a/src/Aspire.Cli/Commands/CacheCommand.cs +++ b/src/Aspire.Cli/Commands/CacheCommand.cs @@ -32,7 +32,7 @@ protected override Task ExecuteAsync(ParseResult parseResult, CancellationT return Task.FromResult(ExitCodeConstants.InvalidCommand); } - private sealed class ClearCommand : BaseCommand + internal sealed class ClearCommand : BaseCommand { public ClearCommand(IInteractionService interactionService, IFeatures features, ICliUpdateNotifier updateNotifier, CliExecutionContext executionContext, AspireCliTelemetry telemetry) : base("clear", CacheCommandStrings.ClearCommand_Description, features, updateNotifier, executionContext, interactionService, telemetry) @@ -45,108 +45,15 @@ protected override Task ExecuteAsync(ParseResult parseResult, CancellationT { try { - var cacheDirectory = ExecutionContext.CacheDirectory; var filesDeleted = 0; - - // Delete cache files and subdirectories - if (cacheDirectory.Exists) - { - // Delete all cache files and subdirectories - foreach (var file in cacheDirectory.GetFiles("*", SearchOption.AllDirectories)) - { - try - { - file.Delete(); - filesDeleted++; - } - catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) - { - // Continue deleting other files even if some fail - } - } - - // Delete subdirectories - foreach (var directory in cacheDirectory.GetDirectories()) - { - try - { - directory.Delete(recursive: true); - } - catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) - { - // Continue deleting other directories even if some fail - } - } - } - - // Also clear the sdks directory - var sdksDirectory = ExecutionContext.SdksDirectory; - if (sdksDirectory.Exists) - { - foreach (var file in sdksDirectory.GetFiles("*", SearchOption.AllDirectories)) - { - try - { - file.Delete(); - filesDeleted++; - } - catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) - { - // Continue deleting other files even if some fail - } - } - - // Delete subdirectories - foreach (var directory in sdksDirectory.GetDirectories()) - { - try - { - directory.Delete(recursive: true); - } - catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) - { - // Continue deleting other directories even if some fail - } - } - } - - // Also clear the logs directory (skip current process's log file) - var logsDirectory = ExecutionContext.LogsDirectory; var currentLogFilePath = ExecutionContext.LogFilePath; - if (logsDirectory.Exists) - { - foreach (var file in logsDirectory.GetFiles("*", SearchOption.AllDirectories)) - { - // Skip the current process's log file to avoid deleting it while in use - if (file.FullName.Equals(currentLogFilePath, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - try - { - file.Delete(); - filesDeleted++; - } - catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) - { - // Continue deleting other files even if some fail - } - } - - // Delete subdirectories - foreach (var directory in logsDirectory.GetDirectories()) - { - try - { - directory.Delete(recursive: true); - } - catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) - { - // Continue deleting other directories even if some fail - } - } - } + + filesDeleted += ClearDirectoryContents(ExecutionContext.CacheDirectory); + filesDeleted += ClearDirectoryContents(ExecutionContext.SdksDirectory); + filesDeleted += ClearDirectoryContents(ExecutionContext.PackagesDirectory); + filesDeleted += ClearDirectoryContents( + ExecutionContext.LogsDirectory, + skipFile: f => f.FullName.Equals(currentLogFilePath, StringComparison.OrdinalIgnoreCase)); if (filesDeleted == 0) { @@ -167,5 +74,53 @@ protected override Task ExecuteAsync(ParseResult parseResult, CancellationT return Task.FromResult(ExitCodeConstants.InvalidCommand); } } + + private static readonly EnumerationOptions s_enumerationOptions = new() + { + RecurseSubdirectories = true, + IgnoreInaccessible = true + }; + + internal static int ClearDirectoryContents(DirectoryInfo? directory, Func? skipFile = null) + { + if (directory is null || !directory.Exists) + { + return 0; + } + + var filesDeleted = 0; + + foreach (var file in directory.EnumerateFiles("*", s_enumerationOptions)) + { + if (skipFile?.Invoke(file) == true) + { + continue; + } + + try + { + file.Delete(); + filesDeleted++; + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) + { + // Continue deleting other files even if some fail (e.g. locked by a running process) + } + } + + foreach (var subdirectory in directory.EnumerateDirectories()) + { + try + { + subdirectory.Delete(recursive: true); + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) + { + // Continue deleting other directories even if some fail + } + } + + return filesDeleted; + } } } diff --git a/src/Aspire.Cli/Program.cs b/src/Aspire.Cli/Program.cs index 98ecc783e6a..db3e8652f13 100644 --- a/src/Aspire.Cli/Program.cs +++ b/src/Aspire.Cli/Program.cs @@ -515,7 +515,8 @@ private static CliExecutionContext BuildCliExecutionContext(bool debugMode, stri var hivesDirectory = GetHivesDirectory(); var cacheDirectory = GetCacheDirectory(); var sdksDirectory = GetSdksDirectory(); - return new CliExecutionContext(workingDirectory, hivesDirectory, cacheDirectory, sdksDirectory, new DirectoryInfo(logsDirectory), logFilePath, debugMode); + var packagesDirectory = GetPackagesDirectory(); + return new CliExecutionContext(workingDirectory, hivesDirectory, cacheDirectory, sdksDirectory, new DirectoryInfo(logsDirectory), logFilePath, debugMode, packagesDirectory: packagesDirectory); } private static DirectoryInfo GetCacheDirectory() @@ -525,6 +526,13 @@ private static DirectoryInfo GetCacheDirectory() return new DirectoryInfo(cacheDirectoryPath); } + private static DirectoryInfo GetPackagesDirectory() + { + var homeDirectory = GetUsersAspirePath(); + var packagesDirectoryPath = Path.Combine(homeDirectory, "packages"); + return new DirectoryInfo(packagesDirectoryPath); + } + private static void TrySetLocaleOverride(string? localeOverride, ILogger logger, IStartupErrorWriter errorWriter) { if (localeOverride is not null) diff --git a/tests/Aspire.Cli.Tests/Commands/CacheCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/CacheCommandTests.cs index 53929cf7da7..694fa455807 100644 --- a/tests/Aspire.Cli.Tests/Commands/CacheCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/CacheCommandTests.cs @@ -38,4 +38,120 @@ public async Task CacheCommandWithHelpArgumentReturnsZero() var exitCode = await result.InvokeAsync().DefaultTimeout(); Assert.Equal(0, exitCode); } + + [Fact] + public async Task CacheClear_ClearsPackagesDirectory() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var packagesDir = new DirectoryInfo(Path.Combine(workspace.WorkspaceRoot.FullName, ".aspire", "packages")); + var restoreDir = packagesDir.CreateSubdirectory("restore").CreateSubdirectory("ABC123"); + File.WriteAllText(Path.Combine(restoreDir.FullName, "test.dll"), "fake"); + + var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper, options => + { + options.PackagesDirectory = packagesDir; + }); + var provider = services.BuildServiceProvider(); + + var command = provider.GetRequiredService(); + var result = command.Parse("cache clear"); + + var exitCode = await result.InvokeAsync().DefaultTimeout(); + + Assert.Equal(ExitCodeConstants.Success, exitCode); + Assert.False(File.Exists(Path.Combine(restoreDir.FullName, "test.dll"))); + } + + [Fact] + public async Task CacheClear_HandlesNonExistentPackagesDirectory() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var packagesDir = new DirectoryInfo(Path.Combine(workspace.WorkspaceRoot.FullName, ".aspire", "packages-nonexistent")); + + var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper, options => + { + options.PackagesDirectory = packagesDir; + }); + var provider = services.BuildServiceProvider(); + + var command = provider.GetRequiredService(); + var result = command.Parse("cache clear"); + + var exitCode = await result.InvokeAsync().DefaultTimeout(); + + Assert.Equal(ExitCodeConstants.Success, exitCode); + } + + [Fact] + public void ClearDirectoryContents_DeletesFilesAndSubdirectories() + { + var tempDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), $"aspire-test-{Guid.NewGuid():N}")); + try + { + tempDir.Create(); + var subDir = tempDir.CreateSubdirectory("nested"); + File.WriteAllText(Path.Combine(tempDir.FullName, "root.txt"), "root"); + File.WriteAllText(Path.Combine(subDir.FullName, "nested.txt"), "nested"); + + var deleted = CacheCommand.ClearCommand.ClearDirectoryContents(tempDir); + + Assert.Equal(2, deleted); + Assert.Empty(tempDir.GetFiles("*", SearchOption.AllDirectories)); + Assert.Empty(tempDir.GetDirectories()); + } + finally + { + if (tempDir.Exists) + { + tempDir.Delete(recursive: true); + } + } + } + + [Fact] + public void ClearDirectoryContents_RespectsSkipPredicate() + { + var tempDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), $"aspire-test-{Guid.NewGuid():N}")); + try + { + tempDir.Create(); + var keepFile = Path.Combine(tempDir.FullName, "keep.txt"); + var deleteFile = Path.Combine(tempDir.FullName, "delete.txt"); + File.WriteAllText(keepFile, "keep"); + File.WriteAllText(deleteFile, "delete"); + + var deleted = CacheCommand.ClearCommand.ClearDirectoryContents( + tempDir, + skipFile: f => f.Name == "keep.txt"); + + Assert.Equal(1, deleted); + Assert.True(File.Exists(keepFile)); + Assert.False(File.Exists(deleteFile)); + } + finally + { + if (tempDir.Exists) + { + tempDir.Delete(recursive: true); + } + } + } + + [Fact] + public void ClearDirectoryContents_ReturnsZero_WhenDirectoryDoesNotExist() + { + var nonExistent = new DirectoryInfo(Path.Combine(Path.GetTempPath(), $"aspire-test-nonexistent-{Guid.NewGuid():N}")); + + var deleted = CacheCommand.ClearCommand.ClearDirectoryContents(nonExistent); + + Assert.Equal(0, deleted); + } + + [Fact] + public void ClearDirectoryContents_ReturnsZero_WhenNull() + { + var deleted = CacheCommand.ClearCommand.ClearDirectoryContents(null); + + Assert.Equal(0, deleted); + } } diff --git a/tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs b/tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs index 02606af4380..8b7b9c97af0 100644 --- a/tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs +++ b/tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs @@ -247,11 +247,13 @@ private CliExecutionContext CreateDefaultCliExecutionContextFactory(IServiceProv var cacheDirectory = new DirectoryInfo(Path.Combine(WorkingDirectory.FullName, ".aspire", "cache")); var logsDirectory = new DirectoryInfo(Path.Combine(WorkingDirectory.FullName, ".aspire", "logs")); var logFilePath = Path.Combine(logsDirectory.FullName, "test.log"); - return new CliExecutionContext(WorkingDirectory, hivesDirectory, cacheDirectory, new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-sdks")), logsDirectory, logFilePath); + return new CliExecutionContext(WorkingDirectory, hivesDirectory, cacheDirectory, new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-sdks")), logsDirectory, logFilePath, packagesDirectory: PackagesDirectory); } public DirectoryInfo WorkingDirectory { get; set; } + public DirectoryInfo? PackagesDirectory { get; set; } + public Action> ConfigurationCallback { get; set; } = (Dictionary config) => { }; From 96d4ccd3f3ec421bf72e601187f1a65b5686941b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 16:08:19 -0700 Subject: [PATCH 22/49] Bump Microsoft.Bcl.Memory to 10.0.5 to fix CVE-2026-26127 (#15411) Microsoft.Bcl.Memory 10.0.0 has a known high severity vulnerability (GHSA-73j8-2gch-69rq) - a denial of service via out-of-bounds read when decoding malformed Base64Url input. Update to 10.0.5 which includes the fix. Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj b/src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj index 2ba860f8572..fb67b224828 100644 --- a/src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj +++ b/src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj @@ -35,7 +35,7 @@ - + From 76b59760964ab55c8f3b92da8676c75834eca285 Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Thu, 19 Mar 2026 19:21:57 -0400 Subject: [PATCH 23/49] Add AppHost CodeLens and gutter decoration support (#15397) * Add CodeLens and gutter decoration support for AppHost resources * wip * remove status bar strings from branch * Add CodeLens, gutter decorations, and AppHost resource parsers for VS Code extension - Add CodeLens provider showing resource state, actions (start/stop/restart), and view logs - Add gutter decoration provider with colored status circles for resources - Add C# and JS/TS AppHost resource parsers with registry pattern - Add statementStartLine for multi-line fluent chain CodeLens positioning - Add comment-skipping logic so CodeLens appears below comments, above code - Extract shared resource state utilities and resource constants - Add enableCodeLens and enableGutterDecorations settings - Add comprehensive test coverage (parsers, CodeLens, resourceStateUtils) - Only match parent resources (Add* calls), not implicit child resources (With* calls) * Address Copilot review: conditional appHostPath, displayName preference, Unhealthy as error - Guard --apphost flag when appHostPath is falsy in CodeLens commands - Prefer displayName over name in two-pass resource matching - Classify Unhealthy health status as error (not warning) to align with tree view * bump extension version * update config json --- extension/loc/xlf/aspire-vscode.xlf | 18 + extension/package.json | 50 +- extension/package.nls.json | 6 + .../src/editor/AspireCodeLensProvider.ts | 209 ++ .../editor/AspireGutterDecorationProvider.ts | 161 ++ .../editor/parsers/AppHostResourceParser.ts | 73 + .../src/editor/parsers/csharpAppHostParser.ts | 88 + .../src/editor/parsers/jsTsAppHostParser.ts | 87 + extension/src/editor/resourceConstants.ts | 41 + extension/src/editor/resourceStateUtils.ts | 50 + extension/src/extension.ts | 35 + extension/src/loc/strings.ts | 15 + extension/src/test/appHostTreeView.test.ts | 25 +- extension/src/test/codeLens.test.ts | 114 + extension/src/test/parsers.test.ts | 1126 +++++++++ extension/src/test/resourceStateUtils.test.ts | 177 ++ .../src/views/AspireAppHostTreeProvider.ts | 114 +- .../RpsArena/.modules/aspire.ts | 2030 ++++++----------- .../RpsArena/.modules/transport.ts | 11 +- playground/TypeScriptApps/RpsArena/apphost.ts | 1 + .../RpsArena/aspire.config.json | 14 + 21 files changed, 3013 insertions(+), 1432 deletions(-) create mode 100644 extension/src/editor/AspireCodeLensProvider.ts create mode 100644 extension/src/editor/AspireGutterDecorationProvider.ts create mode 100644 extension/src/editor/parsers/AppHostResourceParser.ts create mode 100644 extension/src/editor/parsers/csharpAppHostParser.ts create mode 100644 extension/src/editor/parsers/jsTsAppHostParser.ts create mode 100644 extension/src/editor/resourceConstants.ts create mode 100644 extension/src/editor/resourceStateUtils.ts create mode 100644 extension/src/test/codeLens.test.ts create mode 100644 extension/src/test/parsers.test.ts create mode 100644 extension/src/test/resourceStateUtils.test.ts create mode 100644 playground/TypeScriptApps/RpsArena/aspire.config.json diff --git a/extension/loc/xlf/aspire-vscode.xlf b/extension/loc/xlf/aspire-vscode.xlf index b40d4578b74..70d76245b1d 100644 --- a/extension/loc/xlf/aspire-vscode.xlf +++ b/extension/loc/xlf/aspire-vscode.xlf @@ -37,6 +37,9 @@ Aspire launch configuration already exists in launch.json. + + Aspire resource action + Aspire terminal @@ -112,6 +115,9 @@ Debug Aspire apphost + + Debug Aspire pipeline step + Debug {0} @@ -355,6 +361,9 @@ Restart + + Reveal resource in Aspire panel + Run Aspire apphost @@ -385,12 +394,18 @@ Select the default apphost to launch when starting an Aspire debug session + + Show CodeLens actions (state, restart, stop, logs) inline above resource declarations in apphost files. + Show a notification with a link to open the dashboard. Show all running apphosts + + Show colored status dots in the editor gutter next to resource declarations in apphost files. + Show workspace apphost @@ -448,6 +463,9 @@ Verify Aspire CLI installation + + View Aspire resource logs + View logs diff --git a/extension/package.json b/extension/package.json index 0497a53ab05..76efa790608 100644 --- a/extension/package.json +++ b/extension/package.json @@ -3,7 +3,7 @@ "displayName": "Aspire", "description": "%extension.description%", "publisher": "microsoft-aspire", - "version": "1.0.5", + "version": "1.0.6", "aiKey": "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255", "icon": "dotnet-aspire-logo-128.png", "license": "SEE LICENSE IN LICENSE.TXT", @@ -334,6 +334,26 @@ "command": "aspire-vscode.verifyCliInstalled", "title": "%command.verifyCliInstalled%", "category": "Aspire" + }, + { + "command": "aspire-vscode.codeLensDebugPipelineStep", + "title": "%command.codeLensDebugPipelineStep%", + "category": "Aspire" + }, + { + "command": "aspire-vscode.codeLensResourceAction", + "title": "%command.codeLensResourceAction%", + "category": "Aspire" + }, + { + "command": "aspire-vscode.codeLensViewLogs", + "title": "%command.codeLensViewLogs%", + "category": "Aspire" + }, + { + "command": "aspire-vscode.codeLensRevealResource", + "title": "%command.codeLensRevealResource%", + "category": "Aspire" } ], "jsonValidation": [ @@ -416,6 +436,22 @@ "command": "aspire-vscode.executeResourceCommand", "when": "false" }, + { + "command": "aspire-vscode.codeLensDebugPipelineStep", + "when": "false" + }, + { + "command": "aspire-vscode.codeLensResourceAction", + "when": "false" + }, + { + "command": "aspire-vscode.codeLensViewLogs", + "when": "false" + }, + { + "command": "aspire-vscode.codeLensRevealResource", + "when": "false" + }, { "command": "aspire-vscode.switchToGlobalView", "when": "false" @@ -622,6 +658,18 @@ "minimum": 1000, "description": "%configuration.aspire.globalAppHostsPollingInterval%", "scope": "window" + }, + "aspire.enableCodeLens": { + "type": "boolean", + "default": true, + "description": "%configuration.aspire.enableCodeLens%", + "scope": "window" + }, + "aspire.enableGutterDecorations": { + "type": "boolean", + "default": true, + "description": "%configuration.aspire.enableGutterDecorations%", + "scope": "window" } } }, diff --git a/extension/package.nls.json b/extension/package.nls.json index 693a4a15529..1277348603a 100644 --- a/extension/package.nls.json +++ b/extension/package.nls.json @@ -37,6 +37,8 @@ "configuration.aspire.enableDebugConfigEnvironmentLogging": "Include environment variables when logging debug session configurations. This can help diagnose environment-related issues but may expose sensitive information in logs.", "configuration.aspire.registerMcpServerInWorkspace": "Whether to register the Aspire MCP server when a workspace is open.", "configuration.aspire.globalAppHostsPollingInterval": "Polling interval in milliseconds for fetching all running apphosts (used in global view). Minimum: 1000.", + "configuration.aspire.enableCodeLens": "Show CodeLens actions (state, restart, stop, logs) inline above resource declarations in apphost files.", + "configuration.aspire.enableGutterDecorations": "Show colored status dots in the editor gutter next to resource declarations in apphost files.", "command.runAppHost": "Run Aspire apphost", "command.debugAppHost": "Debug Aspire apphost", "aspire-vscode.strings.noCsprojFound": "No apphost found in the current workspace.", @@ -140,6 +142,10 @@ "command.installCliStable": "Install Aspire CLI (stable)", "command.installCliDaily": "Install Aspire CLI (daily)", "command.verifyCliInstalled": "Verify Aspire CLI installation", + "command.codeLensDebugPipelineStep": "Debug Aspire pipeline step", + "command.codeLensResourceAction": "Aspire resource action", + "command.codeLensRevealResource": "Reveal resource in Aspire panel", + "command.codeLensViewLogs": "View Aspire resource logs", "walkthrough.getStarted.title": "Get started with Aspire", "walkthrough.getStarted.description": "Learn how to create, run, and monitor distributed applications with Aspire.", "walkthrough.getStarted.welcome.title": "Welcome to Aspire", diff --git a/extension/src/editor/AspireCodeLensProvider.ts b/extension/src/editor/AspireCodeLensProvider.ts new file mode 100644 index 00000000000..c84179b1cf7 --- /dev/null +++ b/extension/src/editor/AspireCodeLensProvider.ts @@ -0,0 +1,209 @@ +import * as vscode from 'vscode'; +import { getParserForDocument } from './parsers/AppHostResourceParser'; +// Import parsers to trigger self-registration +import './parsers/csharpAppHostParser'; +import './parsers/jsTsAppHostParser'; +import { AspireAppHostTreeProvider } from '../views/AspireAppHostTreeProvider'; +import { ResourceJson, AppHostDisplayInfo, ResourceCommandJson } from '../views/AppHostDataRepository'; +import { findResourceState, findWorkspaceResourceState } from './resourceStateUtils'; +import { ResourceState, HealthStatus, StateStyle, ResourceType } from './resourceConstants'; +import { + codeLensDebugPipelineStep, + codeLensResourceRunning, + codeLensResourceRunningWarning, + codeLensResourceRunningError, + codeLensResourceStarting, + codeLensResourceStopped, + codeLensResourceStoppedError, + codeLensResourceError, + codeLensRestart, + codeLensStop, + codeLensStart, + codeLensViewLogs, + codeLensCommand, +} from '../loc/strings'; + +export class AspireCodeLensProvider implements vscode.CodeLensProvider { + private readonly _onDidChangeCodeLenses = new vscode.EventEmitter(); + readonly onDidChangeCodeLenses = this._onDidChangeCodeLenses.event; + + private _disposables: vscode.Disposable[] = []; + + constructor(private readonly _treeProvider: AspireAppHostTreeProvider) { + // Re-compute lenses whenever the polling data changes + this._disposables.push( + _treeProvider.onDidChangeTreeData(() => this._onDidChangeCodeLenses.fire()) + ); + } + + provideCodeLenses(document: vscode.TextDocument, _token: vscode.CancellationToken): vscode.CodeLens[] { + if (!vscode.workspace.getConfiguration('aspire').get('enableCodeLens', true)) { + return []; + } + + const parser = getParserForDocument(document); + if (!parser) { + return []; + } + + const resources = parser.parseResources(document); + if (resources.length === 0) { + return []; + } + + const appHosts = this._treeProvider.appHosts; + const workspaceResources = this._treeProvider.workspaceResources; + const workspaceAppHostPath = this._treeProvider.workspaceAppHostPath ?? ''; + const hasRunningData = appHosts.length > 0 || workspaceResources.length > 0; + const findWorkspace = findWorkspaceResourceState(workspaceResources, workspaceAppHostPath); + + const lenses: vscode.CodeLens[] = []; + + for (const resource of resources) { + // Use statementStartLine to position the CodeLens at the top of a multi-line chain + const lensLine = resource.statementStartLine ?? resource.range.start.line; + const lineRange = new vscode.Range(lensLine, 0, lensLine, 0); + + if (resource.kind === 'pipelineStep') { + // Pipeline steps get Debug lens when no AppHost is running + if (!hasRunningData) { + this._addPipelineStepLenses(lenses, lineRange, resource.name); + } + } else if (resource.kind === 'resource') { + // Resources get state lenses when live data is available + if (hasRunningData) { + const match = findResourceState(appHosts, resource.name) + ?? findWorkspace(resource.name); + if (match) { + this._addStateLenses(lenses, lineRange, match.resource, match.appHost); + } + } + } + } + + return lenses; + } + + private _addPipelineStepLenses(lenses: vscode.CodeLens[], range: vscode.Range, stepName: string): void { + lenses.push(new vscode.CodeLens(range, { + title: codeLensDebugPipelineStep, + command: 'aspire-vscode.codeLensDebugPipelineStep', + tooltip: codeLensDebugPipelineStep, + arguments: [stepName], + })); + } + + private _addStateLenses( + lenses: vscode.CodeLens[], + range: vscode.Range, + resource: ResourceJson, + appHost: AppHostDisplayInfo, + ): void { + const state = resource.state ?? ''; + const stateStyle = resource.stateStyle ?? ''; + const healthStatus = resource.healthStatus; + const commands = resource.commands ? Object.keys(resource.commands) : []; + + // State indicator lens (clickable — reveals resource in tree view) + let stateLabel = getCodeLensStateLabel(state, stateStyle); + if (healthStatus && healthStatus !== HealthStatus.Healthy) { + stateLabel += ` - (${healthStatus})`; + } + lenses.push(new vscode.CodeLens(range, { + title: stateLabel, + command: 'aspire-vscode.codeLensRevealResource', + tooltip: `${resource.displayName ?? resource.name}: ${state}${healthStatus ? ` (${healthStatus})` : ''}`, + arguments: [resource.displayName ?? resource.name], + })); + + // Action lenses based on available commands + if (commands.includes('restart') || commands.includes('resource-restart')) { + lenses.push(new vscode.CodeLens(range, { + title: codeLensRestart, + command: 'aspire-vscode.codeLensResourceAction', + tooltip: codeLensRestart, + arguments: [resource.name, 'restart', appHost.appHostPath], + })); + } + + if (commands.includes('stop') || commands.includes('resource-stop')) { + lenses.push(new vscode.CodeLens(range, { + title: codeLensStop, + command: 'aspire-vscode.codeLensResourceAction', + tooltip: codeLensStop, + arguments: [resource.name, 'stop', appHost.appHostPath], + })); + } + + if (commands.includes('start') || commands.includes('resource-start')) { + lenses.push(new vscode.CodeLens(range, { + title: codeLensStart, + command: 'aspire-vscode.codeLensResourceAction', + tooltip: codeLensStart, + arguments: [resource.name, 'start', appHost.appHostPath], + })); + } + + // View Logs lens (not applicable to parameters) + if (resource.resourceType !== ResourceType.Parameter) { + lenses.push(new vscode.CodeLens(range, { + title: codeLensViewLogs, + command: 'aspire-vscode.codeLensViewLogs', + tooltip: codeLensViewLogs, + arguments: [resource.displayName ?? resource.name, appHost.appHostPath], + })); + } + + // Custom commands (non-standard ones like "Reset Database") + const standardCommands = new Set(['restart', 'resource-restart', 'stop', 'resource-stop', 'start', 'resource-start']); + if (resource.commands) { + for (const [cmdName, cmd] of Object.entries(resource.commands) as [string, ResourceCommandJson][]) { + if (!standardCommands.has(cmdName)) { + const label = codeLensCommand(cmd.description ?? cmdName); + lenses.push(new vscode.CodeLens(range, { + title: label, + command: 'aspire-vscode.codeLensResourceAction', + tooltip: cmd.description ?? cmdName, + arguments: [resource.name, cmdName, appHost.appHostPath], + })); + } + } + } + } + + dispose(): void { + this._disposables.forEach(d => d.dispose()); + this._onDidChangeCodeLenses.dispose(); + } +} + +export function getCodeLensStateLabel(state: string, stateStyle: string): string { + switch (state) { + case ResourceState.Running: + case ResourceState.Active: + if (stateStyle === StateStyle.Error) { + return codeLensResourceRunningError; + } + if (stateStyle === StateStyle.Warning) { + return codeLensResourceRunningWarning; + } + return codeLensResourceRunning; + case ResourceState.Starting: + case ResourceState.Building: + case ResourceState.Waiting: + case ResourceState.NotStarted: + return codeLensResourceStarting; + case ResourceState.FailedToStart: + case ResourceState.RuntimeUnhealthy: + return codeLensResourceError; + case ResourceState.Finished: + case ResourceState.Exited: + case ResourceState.Stopping: + if (stateStyle === StateStyle.Error) { + return codeLensResourceStoppedError; + } + return codeLensResourceStopped; + default: + return state || codeLensResourceStopped; + } +} diff --git a/extension/src/editor/AspireGutterDecorationProvider.ts b/extension/src/editor/AspireGutterDecorationProvider.ts new file mode 100644 index 00000000000..c9a8df36d03 --- /dev/null +++ b/extension/src/editor/AspireGutterDecorationProvider.ts @@ -0,0 +1,161 @@ +import * as vscode from 'vscode'; +import { getParserForDocument } from './parsers/AppHostResourceParser'; +// Trigger parser self-registration +import './parsers/csharpAppHostParser'; +import './parsers/jsTsAppHostParser'; +import { AspireAppHostTreeProvider } from '../views/AspireAppHostTreeProvider'; +import { findResourceState, findWorkspaceResourceState } from './resourceStateUtils'; +import { ResourceState, StateStyle, HealthStatus } from './resourceConstants'; + +type GutterCategory = 'running' | 'warning' | 'error' | 'starting' | 'stopped'; + +const gutterCategories: GutterCategory[] = ['running', 'warning', 'error', 'starting', 'stopped']; + +const gutterColors: Record = { + running: '#28a745', // green + warning: '#e0a30b', // yellow/amber + error: '#d73a49', // red + starting: '#2188ff', // blue + stopped: '#6a737d', // gray +}; + +/** Creates a data-URI SVG of a filled circle with the given color. */ +function makeGutterSvgUri(color: string): vscode.Uri { + const svg = ``; + return vscode.Uri.parse(`data:image/svg+xml;utf8,${encodeURIComponent(svg)}`); +} + +const decorationTypes = Object.fromEntries( + gutterCategories.map(c => [c, vscode.window.createTextEditorDecorationType({ + gutterIconPath: makeGutterSvgUri(gutterColors[c]), + gutterIconSize: '70%', + })]) +) as Record; + +function classifyState(state: string, stateStyle: string, healthStatus: string): GutterCategory { + switch (state) { + case ResourceState.Running: + case ResourceState.Active: + if (stateStyle === StateStyle.Error || healthStatus === HealthStatus.Unhealthy) return 'error'; + if (stateStyle === StateStyle.Warning || healthStatus === HealthStatus.Degraded) return 'warning'; + return 'running'; + case ResourceState.FailedToStart: + case ResourceState.RuntimeUnhealthy: + return 'error'; + case ResourceState.Starting: + case ResourceState.Stopping: + case ResourceState.Building: + case ResourceState.Waiting: + case ResourceState.NotStarted: + return 'starting'; + case ResourceState.Finished: + case ResourceState.Exited: + return stateStyle === StateStyle.Error ? 'error' : 'stopped'; + default: + return 'stopped'; + } +} + +export class AspireGutterDecorationProvider implements vscode.Disposable { + private readonly _disposables: vscode.Disposable[] = []; + private _debounceTimer: ReturnType | undefined; + + constructor(private readonly _treeProvider: AspireAppHostTreeProvider) { + this._disposables.push( + _treeProvider.onDidChangeTreeData(() => this._updateAllVisibleEditors()), + vscode.window.onDidChangeActiveTextEditor(() => this._updateAllVisibleEditors()), + vscode.workspace.onDidChangeTextDocument(e => { + this._debouncedUpdate(e.document); + }), + ); + + // Apply immediately for any already-open editors + this._updateAllVisibleEditors(); + } + + private _debouncedUpdate(document: vscode.TextDocument): void { + if (this._debounceTimer) { + clearTimeout(this._debounceTimer); + } + this._debounceTimer = setTimeout(() => { + this._debounceTimer = undefined; + for (const editor of vscode.window.visibleTextEditors) { + if (editor.document === document) { + this._applyDecorations(editor); + } + } + }, 250); + } + + private _updateAllVisibleEditors(): void { + for (const editor of vscode.window.visibleTextEditors) { + this._applyDecorations(editor); + } + } + + private _applyDecorations(editor: vscode.TextEditor): void { + if (!vscode.workspace.getConfiguration('aspire').get('enableGutterDecorations', true)) { + this._clearDecorations(editor); + return; + } + + const parser = getParserForDocument(editor.document); + if (!parser) { + this._clearDecorations(editor); + return; + } + + const appHosts = this._treeProvider.appHosts; + const workspaceResources = this._treeProvider.workspaceResources; + if (appHosts.length === 0 && workspaceResources.length === 0) { + this._clearDecorations(editor); + return; + } + + const resources = parser.parseResources(editor.document); + if (resources.length === 0) { + this._clearDecorations(editor); + return; + } + + const findWorkspace = findWorkspaceResourceState(workspaceResources, this._treeProvider.workspaceAppHostPath ?? ''); + const buckets = new Map( + gutterCategories.map(c => [c, []]) + ); + + for (const parsed of resources) { + if (parsed.kind !== 'resource') { + continue; + } + const match = findResourceState(appHosts, parsed.name) + ?? findWorkspace(parsed.name); + if (!match) { + continue; + } + + const { resource } = match; + const category = classifyState(resource.state ?? '', resource.stateStyle ?? '', resource.healthStatus ?? ''); + buckets.get(category)!.push({ range: editor.document.lineAt(parsed.range.start.line).range }); + } + + for (const [category, options] of buckets) { + editor.setDecorations(decorationTypes[category], options); + } + } + + private _clearDecorations(editor: vscode.TextEditor): void { + for (const type of Object.values(decorationTypes)) { + editor.setDecorations(type, []); + } + } + + dispose(): void { + if (this._debounceTimer) { + clearTimeout(this._debounceTimer); + } + this._disposables.forEach(d => d.dispose()); + for (const type of Object.values(decorationTypes)) { + type.dispose(); + } + } +} diff --git a/extension/src/editor/parsers/AppHostResourceParser.ts b/extension/src/editor/parsers/AppHostResourceParser.ts new file mode 100644 index 00000000000..42d98ba1973 --- /dev/null +++ b/extension/src/editor/parsers/AppHostResourceParser.ts @@ -0,0 +1,73 @@ +import * as vscode from 'vscode'; + +/** + * Represents a single resource definition found in an AppHost file. + */ +export interface ParsedResource { + /** The resource name passed to the Add* method, e.g. "cache" in AddRedis("cache"). */ + name: string; + /** The method name that added the resource, e.g. "AddRedis". */ + methodName: string; + /** The range in the document covering the Add*("name") call. */ + range: vscode.Range; + /** Whether this is a resource declaration or pipeline step. */ + kind: 'resource' | 'pipelineStep'; + /** The line number of the first line of the full statement chain (e.g. the variable declaration line for a multi-line fluent chain). */ + statementStartLine?: number; +} + +/** + * Language-specific parser that can detect AppHost files and extract resource definitions. + */ +export interface AppHostResourceParser { + /** File extensions this parser handles, e.g. [".cs"]. */ + getSupportedExtensions(): string[]; + + /** Returns true if the given document is an AppHost file for this language. */ + isAppHostFile(document: vscode.TextDocument): boolean; + + /** Parse resource definitions from the document. */ + parseResources(document: vscode.TextDocument): ParsedResource[]; +} + +const _parsers: AppHostResourceParser[] = []; + +export function registerParser(parser: AppHostResourceParser): void { + _parsers.push(parser); +} + +export function getParserForDocument(document: vscode.TextDocument): AppHostResourceParser | undefined { + const ext = getFileExtension(document.uri.fsPath); + return _parsers.find(p => p.getSupportedExtensions().includes(ext) && p.isAppHostFile(document)); +} + +export function getAllParsers(): readonly AppHostResourceParser[] { + return _parsers; +} + +export function getSupportedLanguageIds(): string[] { + const ids = new Set(); + for (const parser of _parsers) { + for (const ext of parser.getSupportedExtensions()) { + const langId = extensionToLanguageId(ext); + if (langId) { + ids.add(langId); + } + } + } + return [...ids]; +} + +function getFileExtension(filePath: string): string { + const lastDot = filePath.lastIndexOf('.'); + return lastDot >= 0 ? filePath.substring(lastDot).toLowerCase() : ''; +} + +function extensionToLanguageId(ext: string): string | undefined { + switch (ext) { + case '.cs': return 'csharp'; + case '.ts': return 'typescript'; + case '.js': return 'javascript'; + default: return undefined; + } +} diff --git a/extension/src/editor/parsers/csharpAppHostParser.ts b/extension/src/editor/parsers/csharpAppHostParser.ts new file mode 100644 index 00000000000..843371f14b8 --- /dev/null +++ b/extension/src/editor/parsers/csharpAppHostParser.ts @@ -0,0 +1,88 @@ +import * as vscode from 'vscode'; +import { AppHostResourceParser, ParsedResource, registerParser } from './AppHostResourceParser'; + +/** + * C# AppHost resource parser. + * Detects AppHost files via SDK directive or DistributedApplication.CreateBuilder pattern, + * then extracts builder.Add*("name") calls. + */ +class CSharpAppHostParser implements AppHostResourceParser { + getSupportedExtensions(): string[] { + return ['.cs']; + } + + isAppHostFile(document: vscode.TextDocument): boolean { + const text = document.getText(); + if (text.includes('#:sdk Aspire.AppHost.Sdk')) { + return true; + } + return text.includes('DistributedApplication.CreateBuilder'); + } + + parseResources(document: vscode.TextDocument): ParsedResource[] { + const text = document.getText(); + const results: ParsedResource[] = []; + + // Match .AddXyz("name") or .AddXyz<...>("name") patterns + const addPattern = /\.(Add\w+)(?:<[^>]*>)?\s*\(\s*"([^"]+)"/g; + let match: RegExpExecArray | null; + + while ((match = addPattern.exec(text)) !== null) { + const methodName = match[1]; + const resourceName = match[2]; + const matchStart = match.index; + const startPos = document.positionAt(matchStart); + const endPos = document.positionAt(matchStart + match[0].length); + + // Find the start of the full statement (walk back to previous semicolon, '{', or start of file) + const statementStartLine = this._findStatementStartLine(text, matchStart, document); + + results.push({ + name: resourceName, + methodName: methodName, + range: new vscode.Range(startPos, endPos), + kind: methodName === 'AddStep' ? 'pipelineStep' : 'resource', + statementStartLine, + }); + } + + return results; + } + + /** + * Walk backwards from the match position to find the first line of the statement. + * Stops at the previous ';', '{', or start of file, then returns the first non-comment, + * non-blank line after that delimiter. + */ + private _findStatementStartLine(text: string, matchIndex: number, document: vscode.TextDocument): number { + let i = matchIndex - 1; + while (i >= 0) { + const ch = text[i]; + if (ch === ';' || ch === '{') { + break; + } + i--; + } + // i is now at the delimiter or -1 (start of file) + // Find the first non-whitespace character after the delimiter + let start = i + 1; + while (start < matchIndex && /\s/.test(text[start])) { + start++; + } + let line = document.positionAt(start).line; + const matchLine = document.positionAt(matchIndex).line; + // Skip lines that are comments (// or /* or * continuation) + while (line < matchLine) { + const lineText = document.lineAt(line).text.trimStart(); + if (lineText.startsWith('//') || lineText.startsWith('/*') || lineText.startsWith('*')) { + line++; + } else { + break; + } + } + return line; + } +} + +// Self-register on import +registerParser(new CSharpAppHostParser()); diff --git a/extension/src/editor/parsers/jsTsAppHostParser.ts b/extension/src/editor/parsers/jsTsAppHostParser.ts new file mode 100644 index 00000000000..4988682c686 --- /dev/null +++ b/extension/src/editor/parsers/jsTsAppHostParser.ts @@ -0,0 +1,87 @@ +import * as vscode from 'vscode'; +import { AppHostResourceParser, ParsedResource, registerParser } from './AppHostResourceParser'; + +/** + * JavaScript / TypeScript AppHost resource parser. + * Detects AppHost files via Aspire module imports, then extracts .add*("name") calls. + */ +class JsTsAppHostParser implements AppHostResourceParser { + getSupportedExtensions(): string[] { + return ['.ts', '.js']; + } + + isAppHostFile(document: vscode.TextDocument): boolean { + const text = document.getText(); + // Match @aspire package imports, local aspire module imports (e.g. ./.modules/aspire.js), + // or the createBuilder() entry point from the Aspire TS SDK. + return /(?:from\s+['"](?:@aspire|[^'"]*aspire[^'"]*)|require\s*\(\s*['"](?:@aspire|[^'"]*aspire[^'"]*))/.test(text) + || /\bcreateBuilder\s*\(/.test(text); + } + + parseResources(document: vscode.TextDocument): ParsedResource[] { + const text = document.getText(); + const results: ParsedResource[] = []; + + // Match .addXyz("name") or .addXyz('name') patterns + // \s* matches whitespace including newlines, supporting multi-line calls + const pattern = /\.(add\w+)\s*\(\s*(['"])([^'"]+)\2/gi; + let match: RegExpExecArray | null; + + while ((match = pattern.exec(text)) !== null) { + const methodName = match[1]; + const resourceName = match[3]; + + const matchStart = match.index; + const startPos = document.positionAt(matchStart); + const endPos = document.positionAt(matchStart + match[0].length); + + // Find the start of the full statement (walk back to previous ';', '{', or start of file) + const statementStartLine = this._findStatementStartLine(text, matchStart, document); + + results.push({ + name: resourceName, + methodName: methodName, + range: new vscode.Range(startPos, endPos), + kind: methodName.toLowerCase() === 'addstep' ? 'pipelineStep' : 'resource', + statementStartLine, + }); + } + + return results; + } + + /** + * Walk backwards from the match position to find the first line of the statement. + * Stops at the previous ';', '{', or start of file, then returns the first non-comment, + * non-blank line after that delimiter. + */ + private _findStatementStartLine(text: string, matchIndex: number, document: vscode.TextDocument): number { + let i = matchIndex - 1; + while (i >= 0) { + const ch = text[i]; + if (ch === ';' || ch === '{') { + break; + } + i--; + } + let start = i + 1; + while (start < matchIndex && /\s/.test(text[start])) { + start++; + } + let line = document.positionAt(start).line; + const matchLine = document.positionAt(matchIndex).line; + // Skip lines that are comments (// or /* or * continuation) + while (line < matchLine) { + const lineText = document.lineAt(line).text.trimStart(); + if (lineText.startsWith('//') || lineText.startsWith('/*') || lineText.startsWith('*')) { + line++; + } else { + break; + } + } + return line; + } +} + +// Self-register on import +registerParser(new JsTsAppHostParser()); diff --git a/extension/src/editor/resourceConstants.ts b/extension/src/editor/resourceConstants.ts new file mode 100644 index 00000000000..d09ce17a62a --- /dev/null +++ b/extension/src/editor/resourceConstants.ts @@ -0,0 +1,41 @@ +// Resource state values returned by the Aspire runtime +export const ResourceState = { + Running: 'Running', + Active: 'Active', + Starting: 'Starting', + Building: 'Building', + Stopping: 'Stopping', + Stopped: 'Stopped', + Waiting: 'Waiting', + NotStarted: 'NotStarted', + Finished: 'Finished', + Exited: 'Exited', + FailedToStart: 'FailedToStart', + RuntimeUnhealthy: 'RuntimeUnhealthy', +} as const; + +// Health status values returned by the Aspire runtime +export const HealthStatus = { + Healthy: 'Healthy', + Unhealthy: 'Unhealthy', + Degraded: 'Degraded', +} as const; + +// State style values used for visual presentation +export const StateStyle = { + Error: 'error', + Warning: 'warning', +} as const; + +// Resource type values +export const ResourceType = { + Project: 'Project', + Container: 'Container', + Executable: 'Executable', + Parameter: 'Parameter', +} as const; + +export type ResourceStateValue = typeof ResourceState[keyof typeof ResourceState]; +export type HealthStatusValue = typeof HealthStatus[keyof typeof HealthStatus]; +export type StateStyleValue = typeof StateStyle[keyof typeof StateStyle]; +export type ResourceTypeValue = typeof ResourceType[keyof typeof ResourceType]; diff --git a/extension/src/editor/resourceStateUtils.ts b/extension/src/editor/resourceStateUtils.ts new file mode 100644 index 00000000000..0227c4f337b --- /dev/null +++ b/extension/src/editor/resourceStateUtils.ts @@ -0,0 +1,50 @@ +import { ResourceJson, AppHostDisplayInfo } from '../views/AppHostDataRepository'; + +export interface ResourceMatch { + resource: ResourceJson; + appHost: AppHostDisplayInfo; +} + +export function findResourceState( + appHosts: readonly AppHostDisplayInfo[], + resourceName: string, +): ResourceMatch | undefined { + for (const appHost of appHosts) { + if (!appHost.resources) { + continue; + } + // Prefer displayName because the runtime `name` field includes a random suffix + // (e.g., "postgres-fbnfwdfv"), whereas displayName matches the source code name. + const resource = + appHost.resources.find((r: ResourceJson) => r.displayName === resourceName) ?? + appHost.resources.find((r: ResourceJson) => r.name === resourceName); + if (resource) { + return { resource, appHost }; + } + } + return undefined; +} + +export function findWorkspaceResourceState( + workspaceResources: readonly ResourceJson[], + workspaceAppHostPath: string, +): (resourceName: string) => ResourceMatch | undefined { + return (resourceName: string) => { + const resource = + workspaceResources.find((r: ResourceJson) => r.displayName === resourceName) ?? + workspaceResources.find((r: ResourceJson) => r.name === resourceName); + if (resource) { + return { + resource, + appHost: { + appHostPath: workspaceAppHostPath, + appHostPid: 0, + cliPid: null, + dashboardUrl: null, + resources: [...workspaceResources], + }, + }; + } + return undefined; + }; +} diff --git a/extension/src/extension.ts b/extension/src/extension.ts index b74c87365b8..36e3543519f 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -29,6 +29,9 @@ import { AspireAppHostTreeProvider } from './views/AspireAppHostTreeProvider'; import { AppHostDataRepository } from './views/AppHostDataRepository'; import { installCliStableCommand, installCliDailyCommand, verifyCliInstalledCommand } from './commands/walkthroughCommands'; import { AspireMcpServerDefinitionProvider } from './mcp/AspireMcpServerDefinitionProvider'; +import { AspireCodeLensProvider } from './editor/AspireCodeLensProvider'; +import { AspireGutterDecorationProvider } from './editor/AspireGutterDecorationProvider'; +import { getSupportedLanguageIds } from './editor/parsers/AppHostResourceParser'; let aspireExtensionContext = new AspireExtensionContext(); @@ -113,6 +116,38 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(appHostTreeView, refreshRunningAppHostsRegistration, switchToGlobalViewRegistration, switchToWorkspaceViewRegistration, openDashboardRegistration, stopAppHostRegistration, stopResourceRegistration, startResourceRegistration, restartResourceRegistration, viewResourceLogsRegistration, executeResourceCommandRegistration, copyEndpointUrlRegistration, openInExternalBrowserRegistration, openInSimpleBrowserRegistration, copyResourceNameRegistration, copyPidRegistration, copyAppHostPathRegistration, { dispose: () => { appHostTreeProvider.dispose(); dataRepository.dispose(); } }); + // CodeLens provider — shows Debug on pipeline steps, resource state on resources + const codeLensProvider = new AspireCodeLensProvider(appHostTreeProvider); + const languageFilters = getSupportedLanguageIds().map(lang => ({ language: lang, scheme: 'file' })); + const codeLensRegistration = vscode.languages.registerCodeLensProvider(languageFilters, codeLensProvider); + const codeLensDebugPipelineStepRegistration = vscode.commands.registerCommand('aspire-vscode.codeLensDebugPipelineStep', (stepName: string) => editorCommandProvider.tryExecuteDoAppHost(false, stepName)); + const codeLensResourceActionRegistration = vscode.commands.registerCommand('aspire-vscode.codeLensResourceAction', (resourceName: string, action: string, appHostPath: string) => { + let command = `resource "${resourceName}" ${action}`; + if (appHostPath) { + command += ` --apphost "${appHostPath}"`; + } + terminalProvider.sendAspireCommandToAspireTerminal(command); + }); + const codeLensViewLogsRegistration = vscode.commands.registerCommand('aspire-vscode.codeLensViewLogs', (resourceName: string, appHostPath: string) => { + let command = `logs "${resourceName}"`; + if (appHostPath) { + command += ` --apphost "${appHostPath}"`; + } + command += ' --follow'; + terminalProvider.sendAspireCommandToAspireTerminal(command); + }); + const codeLensRevealResourceRegistration = vscode.commands.registerCommand('aspire-vscode.codeLensRevealResource', (resourceName: string) => { + const element = appHostTreeProvider.findResourceElement(resourceName); + if (element) { + appHostTreeView.reveal(element, { select: true, focus: true }); + } + }); + context.subscriptions.push(codeLensRegistration, codeLensDebugPipelineStepRegistration, codeLensResourceActionRegistration, codeLensViewLogsRegistration, codeLensRevealResourceRegistration, codeLensProvider); + + // Gutter decorations — colored dots next to resources showing runtime state + const gutterDecorationProvider = new AspireGutterDecorationProvider(appHostTreeProvider); + context.subscriptions.push(gutterDecorationProvider); + context.subscriptions.push(cliAddCommandRegistration, cliNewCommandRegistration, cliInitCommandRegistration, cliDeployCommandRegistration, cliPublishCommandRegistration, cliDoCommandRegistration, openTerminalCommandRegistration, configureLaunchJsonCommandRegistration); context.subscriptions.push(cliUpdateCommandRegistration, cliUpdateSelfCommandRegistration, settingsCommandRegistration, openLocalSettingsCommandRegistration, openGlobalSettingsCommandRegistration, runAppHostCommandRegistration, debugAppHostCommandRegistration); context.subscriptions.push(installCliStableRegistration, installCliDailyRegistration, verifyCliInstalledRegistration); diff --git a/extension/src/loc/strings.ts b/extension/src/loc/strings.ts index d65d03d95f7..e1c2e7c3598 100644 --- a/extension/src/loc/strings.ts +++ b/extension/src/loc/strings.ts @@ -97,3 +97,18 @@ export const cliFoundAtDefaultPath = (path: string) => vscode.l10n.t('Aspire CLI export const selectDirectoryTitle = vscode.l10n.t('Select directory'); export const selectFileTitle = vscode.l10n.t('Select file'); export const enterPipelineStep = vscode.l10n.t('Enter the pipeline step to execute'); + +// CodeLens strings +export const codeLensDebugPipelineStep = vscode.l10n.t('$(bug) Debug pipeline step'); +export const codeLensResourceRunning = vscode.l10n.t('$(pass) Running'); +export const codeLensResourceRunningWarning = vscode.l10n.t('$(warning) Running'); +export const codeLensResourceRunningError = vscode.l10n.t('$(error) Running'); +export const codeLensResourceStarting = vscode.l10n.t('$(loading~spin) Starting'); +export const codeLensResourceStopped = vscode.l10n.t('$(circle-outline) Stopped'); +export const codeLensResourceStoppedError = vscode.l10n.t('$(error) Stopped'); +export const codeLensResourceError = vscode.l10n.t('$(error) Error'); +export const codeLensRestart = vscode.l10n.t('$(debug-restart) Restart'); +export const codeLensStop = vscode.l10n.t('$(debug-stop) Stop'); +export const codeLensStart = vscode.l10n.t('$(debug-start) Start'); +export const codeLensViewLogs = vscode.l10n.t('$(output) Logs'); +export const codeLensCommand = (name: string) => vscode.l10n.t('$(terminal) {0}', name); diff --git a/extension/src/test/appHostTreeView.test.ts b/extension/src/test/appHostTreeView.test.ts index 43aad8b5ae0..e5b30c575f4 100644 --- a/extension/src/test/appHostTreeView.test.ts +++ b/extension/src/test/appHostTreeView.test.ts @@ -2,6 +2,7 @@ import * as assert from 'assert'; import { shortenPath } from '../views/AppHostDataRepository'; import { getResourceContextValue, getResourceIcon } from '../views/AspireAppHostTreeProvider'; import type { ResourceJson } from '../views/AppHostDataRepository'; +import { ResourceState, HealthStatus, StateStyle } from '../editor/resourceConstants'; function makeResource(overrides: Partial = {}): ResourceJson { const base: ResourceJson = { @@ -103,62 +104,62 @@ suite('getResourceContextValue', () => { suite('getResourceIcon', () => { test('Running + Healthy shows pass icon', () => { - const icon = getResourceIcon(makeResource({ state: 'Running', healthStatus: 'Healthy' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Running, healthStatus: HealthStatus.Healthy })); assert.strictEqual(icon.id, 'pass'); }); test('Running + Unhealthy shows error icon', () => { - const icon = getResourceIcon(makeResource({ state: 'Running', healthStatus: 'Unhealthy' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Running, healthStatus: HealthStatus.Unhealthy })); assert.strictEqual(icon.id, 'error'); }); test('Running + Degraded shows warning icon', () => { - const icon = getResourceIcon(makeResource({ state: 'Running', healthStatus: 'Degraded' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Running, healthStatus: HealthStatus.Degraded })); assert.strictEqual(icon.id, 'warning'); }); test('Running + error stateStyle shows error icon', () => { - const icon = getResourceIcon(makeResource({ state: 'Running', stateStyle: 'error' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Running, stateStyle: StateStyle.Error })); assert.strictEqual(icon.id, 'error'); }); test('Running + warning stateStyle shows warning icon', () => { - const icon = getResourceIcon(makeResource({ state: 'Running', stateStyle: 'warning' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Running, stateStyle: StateStyle.Warning })); assert.strictEqual(icon.id, 'warning'); }); test('Active state treated same as Running', () => { - const icon = getResourceIcon(makeResource({ state: 'Active' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Active })); assert.strictEqual(icon.id, 'pass'); }); test('Finished shows circle-outline', () => { - const icon = getResourceIcon(makeResource({ state: 'Finished' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Finished })); assert.strictEqual(icon.id, 'circle-outline'); }); test('Exited with error stateStyle shows error', () => { - const icon = getResourceIcon(makeResource({ state: 'Exited', stateStyle: 'error' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Exited, stateStyle: StateStyle.Error })); assert.strictEqual(icon.id, 'error'); }); test('FailedToStart shows error icon', () => { - const icon = getResourceIcon(makeResource({ state: 'FailedToStart' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.FailedToStart })); assert.strictEqual(icon.id, 'error'); }); test('RuntimeUnhealthy shows error icon', () => { - const icon = getResourceIcon(makeResource({ state: 'RuntimeUnhealthy' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.RuntimeUnhealthy })); assert.strictEqual(icon.id, 'error'); }); test('Starting shows loading spinner', () => { - const icon = getResourceIcon(makeResource({ state: 'Starting' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Starting })); assert.strictEqual(icon.id, 'loading~spin'); }); test('Building shows loading spinner', () => { - const icon = getResourceIcon(makeResource({ state: 'Building' })); + const icon = getResourceIcon(makeResource({ state: ResourceState.Building })); assert.strictEqual(icon.id, 'loading~spin'); }); diff --git a/extension/src/test/codeLens.test.ts b/extension/src/test/codeLens.test.ts new file mode 100644 index 00000000000..0f6a48ed242 --- /dev/null +++ b/extension/src/test/codeLens.test.ts @@ -0,0 +1,114 @@ +import * as assert from 'assert'; +import { getCodeLensStateLabel } from '../editor/AspireCodeLensProvider'; +import { + codeLensResourceRunning, + codeLensResourceRunningWarning, + codeLensResourceRunningError, + codeLensResourceStarting, + codeLensResourceStopped, + codeLensResourceStoppedError, + codeLensResourceError, +} from '../loc/strings'; +import { ResourceState, StateStyle } from '../editor/resourceConstants'; + +suite('getCodeLensStateLabel', () => { + // --- Running / Active states --- + + test('Running with no stateStyle returns running label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Running, ''), codeLensResourceRunning); + }); + + test('Active with no stateStyle returns running label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Active, ''), codeLensResourceRunning); + }); + + test('Running with error stateStyle returns running-error label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Running, StateStyle.Error), codeLensResourceRunningError); + }); + + test('Running with warning stateStyle returns running-warning label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Running, StateStyle.Warning), codeLensResourceRunningWarning); + }); + + test('Active with error stateStyle returns running-error label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Active, StateStyle.Error), codeLensResourceRunningError); + }); + + test('Active with warning stateStyle returns running-warning label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Active, StateStyle.Warning), codeLensResourceRunningWarning); + }); + + // --- Starting states --- + + test('Starting returns starting label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Starting, ''), codeLensResourceStarting); + }); + + test('Building returns starting label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Building, ''), codeLensResourceStarting); + }); + + test('Waiting returns starting label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Waiting, ''), codeLensResourceStarting); + }); + + test('NotStarted returns starting label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.NotStarted, ''), codeLensResourceStarting); + }); + + // --- Error states --- + + test('FailedToStart returns error label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.FailedToStart, ''), codeLensResourceError); + }); + + test('RuntimeUnhealthy returns error label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.RuntimeUnhealthy, ''), codeLensResourceError); + }); + + // --- Stopped states --- + + test('Finished with no stateStyle returns stopped label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Finished, ''), codeLensResourceStopped); + }); + + test('Exited with no stateStyle returns stopped label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Exited, ''), codeLensResourceStopped); + }); + + test('Stopping with no stateStyle returns stopped label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Stopping, ''), codeLensResourceStopped); + }); + + test('Finished with error stateStyle returns stopped-error label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Finished, StateStyle.Error), codeLensResourceStoppedError); + }); + + test('Exited with error stateStyle returns stopped-error label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Exited, StateStyle.Error), codeLensResourceStoppedError); + }); + + test('Stopping with error stateStyle returns stopped-error label', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Stopping, StateStyle.Error), codeLensResourceStoppedError); + }); + + // --- Default / unknown states --- + + test('unknown state returns the state string itself', () => { + assert.strictEqual(getCodeLensStateLabel('SomeUnknownState', ''), 'SomeUnknownState'); + }); + + test('empty state returns stopped label', () => { + assert.strictEqual(getCodeLensStateLabel('', ''), codeLensResourceStopped); + }); + + // --- stateStyle is ignored for non-Running/non-Finished states --- + + test('Starting ignores error stateStyle', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.Starting, StateStyle.Error), codeLensResourceStarting); + }); + + test('FailedToStart ignores stateStyle', () => { + assert.strictEqual(getCodeLensStateLabel(ResourceState.FailedToStart, StateStyle.Warning), codeLensResourceError); + }); +}); diff --git a/extension/src/test/parsers.test.ts b/extension/src/test/parsers.test.ts new file mode 100644 index 00000000000..af7f6935001 --- /dev/null +++ b/extension/src/test/parsers.test.ts @@ -0,0 +1,1126 @@ +import * as assert from 'assert'; +import * as vscode from 'vscode'; +import { getParserForDocument, getSupportedLanguageIds, getAllParsers, ParsedResource } from '../editor/parsers/AppHostResourceParser'; +// Import parsers so they self-register +import '../editor/parsers/csharpAppHostParser'; +import '../editor/parsers/jsTsAppHostParser'; + +/** + * Creates a minimal mock TextDocument for parser testing. + */ +function createMockDocument(content: string, filePath: string): vscode.TextDocument { + const lines = content.split('\n'); + return { + uri: vscode.Uri.file(filePath), + fileName: filePath, + isUntitled: false, + languageId: filePath.endsWith('.cs') ? 'csharp' : filePath.endsWith('.ts') ? 'typescript' : 'javascript', + version: 1, + isDirty: false, + isClosed: false, + eol: vscode.EndOfLine.LF, + lineCount: lines.length, + encoding: 'utf-8', + save: () => Promise.resolve(false), + lineAt: (lineOrPos: number | vscode.Position) => { + const lineNum = typeof lineOrPos === 'number' ? lineOrPos : lineOrPos.line; + const text = lines[lineNum] || ''; + return { + lineNumber: lineNum, + text, + range: new vscode.Range(lineNum, 0, lineNum, text.length), + rangeIncludingLineBreak: new vscode.Range(lineNum, 0, lineNum + 1, 0), + firstNonWhitespaceCharacterIndex: text.search(/\S/), + isEmptyOrWhitespace: text.trim().length === 0, + } as vscode.TextLine; + }, + offsetAt: (position: vscode.Position) => { + let offset = 0; + for (let i = 0; i < position.line && i < lines.length; i++) { + offset += lines[i].length + 1; // +1 for \n + } + offset += position.character; + return offset; + }, + positionAt: (offset: number) => { + let remaining = offset; + for (let i = 0; i < lines.length; i++) { + if (remaining <= lines[i].length) { + return new vscode.Position(i, remaining); + } + remaining -= lines[i].length + 1; // +1 for \n + } + return new vscode.Position(lines.length - 1, lines[lines.length - 1].length); + }, + getText: (range?: vscode.Range) => { + if (!range) { + return content; + } + const startOffset = lines.slice(0, range.start.line).reduce((sum, l) => sum + l.length + 1, 0) + range.start.character; + const endOffset = lines.slice(0, range.end.line).reduce((sum, l) => sum + l.length + 1, 0) + range.end.character; + return content.substring(startOffset, endOffset); + }, + getWordRangeAtPosition: () => undefined, + validateRange: (range: vscode.Range) => range, + validatePosition: (position: vscode.Position) => position, + notebook: undefined as any, + } as vscode.TextDocument; +} + +// ============================================================ +// Parser Registry Tests +// ============================================================ +suite('AppHostResourceParser registry', () => { + test('getAllParsers returns registered parsers', () => { + const parsers = getAllParsers(); + assert.ok(parsers.length >= 2, 'Should have at least the C# and JS/TS parsers'); + }); + + test('getSupportedLanguageIds returns expected languages', () => { + const ids = getSupportedLanguageIds(); + assert.ok(ids.includes('csharp'), 'Should support csharp'); + assert.ok(ids.includes('typescript'), 'Should support typescript'); + assert.ok(ids.includes('javascript'), 'Should support javascript'); + }); + + test('getParserForDocument returns C# parser for .cs AppHost file', () => { + const doc = createMockDocument( + 'var builder = DistributedApplication.CreateBuilder(args);\nbuilder.AddRedis("cache");', + '/test/AppHost.cs' + ); + const parser = getParserForDocument(doc); + assert.ok(parser, 'Should find a parser'); + assert.ok(parser!.getSupportedExtensions().includes('.cs')); + }); + + test('getParserForDocument returns JS/TS parser for .ts AppHost file', () => { + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nbuilder.addRedis("cache");', + '/test/apphost.ts' + ); + const parser = getParserForDocument(doc); + assert.ok(parser, 'Should find a parser'); + assert.ok(parser!.getSupportedExtensions().includes('.ts')); + }); + + test('getParserForDocument returns undefined for non-AppHost .cs file', () => { + const doc = createMockDocument( + 'using System;\nclass Program { static void Main() { } }', + '/test/Program.cs' + ); + const parser = getParserForDocument(doc); + assert.strictEqual(parser, undefined, 'Should not find a parser for non-AppHost C# file'); + }); + + test('getParserForDocument returns undefined for non-AppHost .ts file', () => { + const doc = createMockDocument( + 'import express from "express";\nconst app = express();', + '/test/server.ts' + ); + const parser = getParserForDocument(doc); + assert.strictEqual(parser, undefined, 'Should not find a parser for non-AppHost TS file'); + }); + + test('getParserForDocument returns undefined for unsupported extension', () => { + const doc = createMockDocument( + 'DistributedApplication.CreateBuilder(args);', + '/test/file.py' + ); + const parser = getParserForDocument(doc); + assert.strictEqual(parser, undefined, 'Should not find a parser for .py file'); + }); + + test('getParserForDocument returns JS/TS parser for .js AppHost file', () => { + const doc = createMockDocument( + 'const { createBuilder } = require("@aspire/sdk");\nbuilder.addRedis("cache");', + '/test/apphost.js' + ); + const parser = getParserForDocument(doc); + assert.ok(parser, 'Should find a parser for .js file'); + assert.ok(parser!.getSupportedExtensions().includes('.js')); + }); +}); + +// ============================================================ +// C# Parser Tests +// ============================================================ +suite('CSharpAppHostParser', () => { + function getCSharpParser() { + return getAllParsers().find(p => p.getSupportedExtensions().includes('.cs'))!; + } + + // --- isAppHostFile --- + + test('detects AppHost via #:sdk directive', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + '#:sdk Aspire.AppHost.Sdk\n\nvar builder = Aspire.Hosting.DistributedApplication.CreateBuilder(args);', + '/test/AppHost.cs' + ); + assert.strictEqual(parser.isAppHostFile(doc), true); + }); + + test('detects AppHost via DistributedApplication.CreateBuilder', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'using Aspire;\nvar builder = DistributedApplication.CreateBuilder(args);', + '/test/Program.cs' + ); + assert.strictEqual(parser.isAppHostFile(doc), true); + }); + + test('rejects non-AppHost C# file', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'using System;\nclass Foo { void Bar() { } }', + '/test/Foo.cs' + ); + assert.strictEqual(parser.isAppHostFile(doc), false); + }); + + // --- parseResources: basic patterns --- + + test('parses single AddRedis call', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'var builder = DistributedApplication.CreateBuilder(args);\nbuilder.AddRedis("cache");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[0].methodName, 'AddRedis'); + }); + + test('parses multiple resource calls', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + 'var redis = builder.AddRedis("cache");', + 'var postgres = builder.AddPostgres("db");', + 'var api = builder.AddProject("api");', + 'builder.Build().Run();', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[0].methodName, 'AddRedis'); + assert.strictEqual(resources[1].name, 'db'); + assert.strictEqual(resources[1].methodName, 'AddPostgres'); + assert.strictEqual(resources[2].name, 'api'); + assert.strictEqual(resources[2].methodName, 'AddProject'); + }); + + test('parses AddProject with generic type parameter', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'var builder = DistributedApplication.CreateBuilder(args);\nbuilder.AddProject("webfrontend");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'webfrontend'); + assert.strictEqual(resources[0].methodName, 'AddProject'); + }); + + test('parses AddContainer call', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'var builder = DistributedApplication.CreateBuilder(args);\nbuilder.AddContainer("mycontainer", "myimage");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'mycontainer'); + assert.strictEqual(resources[0].methodName, 'AddContainer'); + }); + + test('parses calls with whitespace variations', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + 'builder.AddRedis( "spaced" );', + 'builder.AddPostgres(', + ' "multiline"', + ');', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 2); + assert.strictEqual(resources[0].name, 'spaced'); + assert.strictEqual(resources[1].name, 'multiline'); + }); + + test('parses chained calls', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'var builder = DistributedApplication.CreateBuilder(args);\nbuilder.AddRedis("cache").WithEndpoint(port: 6379);', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + const addResources = resources.filter(r => r.kind === 'resource'); + assert.strictEqual(addResources.length, 1); + assert.strictEqual(addResources[0].name, 'cache'); + }); + + // --- parseResources: range accuracy --- + + test('range starts at dot before method name', () => { + const parser = getCSharpParser(); + const line = 'builder.AddRedis("cache");'; + const doc = createMockDocument(line, '/test/AppHost.cs'); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + // ".AddRedis("cache"" starts at index 7 (the dot) + assert.strictEqual(resources[0].range.start.line, 0); + assert.strictEqual(resources[0].range.start.character, 7); + }); + + test('range is on correct line for multi-line file', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + '', + '// Some comment', + 'builder.AddRedis("cache");', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].range.start.line, 3, 'Resource should be on line 3'); + }); + + // --- parseResources: statementStartLine --- + + test('statementStartLine equals range line for single-line call', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'var builder = DistributedApplication.CreateBuilder(args);\nvar cache = builder.AddRedis("cache");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].statementStartLine, resources[0].range.start.line); + }); + + test('statementStartLine points to top of multi-line fluent chain', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + '', + 'var cache = builder', + ' .AddRedis("cache")', + ' .WithLifetime(ContainerLifetime.Persistent);', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + const addResources = resources.filter(r => r.kind === 'resource'); + assert.strictEqual(addResources.length, 1); + assert.strictEqual(addResources[0].range.start.line, 3, '.AddRedis is on line 3'); + assert.strictEqual(addResources[0].statementStartLine, 2, 'statement starts on line 2 (var cache = builder)'); + }); + + test('statementStartLine works with multiple multi-line resources', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + '', + 'var cache = builder', + ' .AddRedis("cache")', + ' .WithLifetime(ContainerLifetime.Persistent);', + '', + 'var db = builder', + ' .AddPostgres("postgres")', + ' .AddDatabase("mydb");', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources[0].statementStartLine, 2, 'cache starts at var cache'); + assert.strictEqual(resources[1].statementStartLine, 6, 'postgres starts at var db'); + }); + + test('statementStartLine points to first line after opening brace', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + '{', + ' builder.AddRedis("cache");', + '}', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].statementStartLine, 2, 'statement starts after {'); + }); + + test('statementStartLine skips single-line comments above statement', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + '', + '// This is the cache resource', + '// It uses Redis', + 'var cache = builder', + ' .AddRedis("cache")', + ' .WithLifetime(ContainerLifetime.Persistent);', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + const addResources = resources.filter(r => r.kind === 'resource'); + assert.strictEqual(addResources.length, 1); + assert.strictEqual(addResources[0].statementStartLine, 4, 'statement starts at var cache, skipping comments'); + }); + + test('statementStartLine skips block comments above statement', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var builder = DistributedApplication.CreateBuilder(args);', + '', + '/* Multi-line', + ' * block comment', + ' */', + 'var cache = builder', + ' .AddRedis("cache");', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].statementStartLine, 5, 'statement starts at var cache, skipping block comment'); + }); + + // --- parseResources: empty / no matches --- + + test('returns empty array for file with no Add* calls', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'var builder = DistributedApplication.CreateBuilder(args);\nbuilder.Build().Run();', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0); + }); + + test('returns empty array for empty document', () => { + const parser = getCSharpParser(); + const doc = createMockDocument('', '/test/Empty.cs'); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0); + }); + + // --- parseResources: edge cases --- + + test('does not match non-Add methods', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'builder.WithReference("notaresource");\nbuilder.ConfigureOpenTelemetry("otel");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0); + }); + + test('does not match lowercase add (C# is PascalCase)', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'builder.addRedis("cache");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0, 'C# parser should only match PascalCase Add* methods'); + }); + + test('matches Add* calls in commented-out code (known regex limitation)', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + '// builder.AddRedis("commented-cache");', + '/* builder.AddPostgres("block-commented"); */', + 'builder.AddRedis("real-cache");', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + // Regex-based parser cannot distinguish comments from code — all three match + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[2].name, 'real-cache'); + }); + + test('does not match string interpolation expressions', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'builder.AddRedis($"cache-{env}");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + // $" prefix means the regex won't match (it expects .Add*("name" not .Add*($"name") + assert.strictEqual(resources.length, 0, 'Interpolated strings should not match'); + }); + + test('range end position is correct', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'builder.AddRedis("cache");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + // .AddRedis("cache" = 17 chars starting at index 7, so end = 7 + 17 = 24 + assert.strictEqual(resources[0].range.end.line, 0); + assert.strictEqual(resources[0].range.end.character, 24); + }); + + test('parses AddDatabase chained off a resource variable', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'var postgres = builder.AddPostgres("pg");\nvar db = postgres.AddDatabase("mydb");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 2); + assert.strictEqual(resources[0].name, 'pg'); + assert.strictEqual(resources[0].methodName, 'AddPostgres'); + assert.strictEqual(resources[1].name, 'mydb'); + assert.strictEqual(resources[1].methodName, 'AddDatabase'); + }); + + test('handles single-quotes inside resource name gracefully', () => { + const parser = getCSharpParser(); + // C# uses double quotes for strings, single quotes in the name itself + const doc = createMockDocument( + 'builder.AddRedis("my-cache");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'my-cache'); + }); + + test('parses resource names with hyphens and underscores', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'builder.AddRedis("my-cache");', + 'builder.AddPostgres("my_db");', + 'builder.AddRabbitMQ("event-bus-01");', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[0].name, 'my-cache'); + assert.strictEqual(resources[1].name, 'my_db'); + assert.strictEqual(resources[2].name, 'event-bus-01'); + }); + + test('parses AddXyz with complex generic parameters', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'builder.AddProject("api");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'api'); + assert.strictEqual(resources[0].methodName, 'AddProject'); + }); + + test('parses realistic full AppHost file', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + '#:sdk Aspire.AppHost.Sdk', + '', + 'var builder = DistributedApplication.CreateBuilder(args);', + '', + 'var cache = builder.AddRedis("cache");', + '', + 'var db = builder.AddPostgres("postgres")', + ' .AddDatabase("catalogdb");', + '', + 'var api = builder.AddProject("catalogapi")', + ' .WithReference(cache)', + ' .WithReference(db);', + '', + 'builder.AddProject("webfrontend")', + ' .WithExternalHttpEndpoints()', + ' .WithReference(api);', + '', + 'builder.Build().Run();', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + const addResources = resources.filter(r => r.kind === 'resource'); + assert.strictEqual(addResources.length, 5); + assert.strictEqual(addResources[0].name, 'cache'); + assert.strictEqual(addResources[0].methodName, 'AddRedis'); + assert.strictEqual(addResources[1].name, 'postgres'); + assert.strictEqual(addResources[1].methodName, 'AddPostgres'); + assert.strictEqual(addResources[2].name, 'catalogdb'); + assert.strictEqual(addResources[2].methodName, 'AddDatabase'); + assert.strictEqual(addResources[3].name, 'catalogapi'); + assert.strictEqual(addResources[3].methodName, 'AddProject'); + assert.strictEqual(addResources[4].name, 'webfrontend'); + assert.strictEqual(addResources[4].methodName, 'AddProject'); + + // All should be classified as resources + for (const r of addResources) { + assert.strictEqual(r.kind, 'resource'); + } + }); + + // --- Pipeline step classification --- + + test('classifies AddStep as pipelineStep', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'builder.Pipeline.AddStep("assign-storage-role", async (context) => { });', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'assign-storage-role'); + assert.strictEqual(resources[0].methodName, 'AddStep'); + assert.strictEqual(resources[0].kind, 'pipelineStep'); + }); + + test('classifies AddRedis as resource, not pipelineStep', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + 'builder.AddRedis("cache");', + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].kind, 'resource'); + }); + + test('parses mixed resources and pipeline steps', () => { + const parser = getCSharpParser(); + const doc = createMockDocument( + [ + 'var cache = builder.AddRedis("cache");', + 'builder.Pipeline.AddStep("deploy-step", async (ctx) => { });', + 'var db = builder.AddPostgres("pg");', + ].join('\n'), + '/test/AppHost.cs' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[0].kind, 'resource'); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[1].kind, 'pipelineStep'); + assert.strictEqual(resources[1].name, 'deploy-step'); + assert.strictEqual(resources[2].kind, 'resource'); + assert.strictEqual(resources[2].name, 'pg'); + }); +}); + +// ============================================================ +// JS/TS Parser Tests +// ============================================================ +suite('JsTsAppHostParser', () => { + function getJsTsParser() { + return getAllParsers().find(p => p.getSupportedExtensions().includes('.ts'))!; + } + + // --- isAppHostFile --- + + test('detects AppHost via ES import from @aspire', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nconst builder = createBuilder();', + '/test/apphost.ts' + ); + assert.strictEqual(parser.isAppHostFile(doc), true); + }); + + test('detects AppHost via require from @aspire', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'const { createBuilder } = require("@aspire/sdk");\nconst builder = createBuilder();', + '/test/apphost.js' + ); + assert.strictEqual(parser.isAppHostFile(doc), true); + }); + + test('detects AppHost via single-quote import', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + "import { createBuilder } from '@aspire/sdk';", + '/test/apphost.ts' + ); + assert.strictEqual(parser.isAppHostFile(doc), true); + }); + + test('detects AppHost via local aspire module import', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + "import { createBuilder } from './.modules/aspire.js';\nconst builder = await createBuilder();", + '/test/apphost.ts' + ); + assert.strictEqual(parser.isAppHostFile(doc), true); + }); + + test('detects AppHost via createBuilder call without aspire import', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + "const builder = await createBuilder();\nawait builder.build().run();", + '/test/apphost.ts' + ); + assert.strictEqual(parser.isAppHostFile(doc), true); + }); + + test('rejects non-AppHost TS file', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import express from "express";\nconst app = express();', + '/test/server.ts' + ); + assert.strictEqual(parser.isAppHostFile(doc), false); + }); + + test('rejects non-AppHost JS file', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'const http = require("http");\nhttp.createServer().listen(3000);', + '/test/index.js' + ); + assert.strictEqual(parser.isAppHostFile(doc), false); + }); + + // --- parseResources: basic patterns --- + + test('parses single addRedis call with double quotes', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nbuilder.addRedis("cache");', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[0].methodName, 'addRedis'); + }); + + test('parses single addRedis call with single quotes', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + "import { createBuilder } from '@aspire/sdk';\nbuilder.addRedis('cache');", + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'cache'); + }); + + test('parses multiple resource calls', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + 'const builder = createBuilder();', + 'builder.addRedis("cache");', + 'builder.addPostgres("db");', + 'builder.addProject("api");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[0].methodName, 'addRedis'); + assert.strictEqual(resources[1].name, 'db'); + assert.strictEqual(resources[1].methodName, 'addPostgres'); + assert.strictEqual(resources[2].name, 'api'); + assert.strictEqual(resources[2].methodName, 'addProject'); + }); + + test('parses chained calls', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nbuilder.addRedis("cache").withEndpoint(6379);', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'cache'); + }); + + test('parses calls with whitespace variations', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + 'builder.addRedis( "spaced" );', + 'builder.addPostgres(', + ' "multiline"', + ');', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 2); + assert.strictEqual(resources[0].name, 'spaced'); + assert.strictEqual(resources[1].name, 'multiline'); + }); + + // --- parseResources: range accuracy --- + + test('range starts at the dot before method name', () => { + const parser = getJsTsParser(); + const line = 'builder.addRedis("cache");'; + const doc = createMockDocument(line, '/test/apphost.ts'); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + // ".addRedis("cache"" starts at index 7 (the dot) + assert.strictEqual(resources[0].range.start.line, 0); + assert.strictEqual(resources[0].range.start.character, 7); + }); + + test('range is on correct line for multi-line file', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + '', + '// comment', + 'builder.addRedis("cache");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].range.start.line, 3, 'Resource should be on line 3'); + }); + + // --- parseResources: statementStartLine --- + + test('statementStartLine equals range line for single-line call', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nconst cache = builder.addRedis("cache");', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].statementStartLine, resources[0].range.start.line); + }); + + test('statementStartLine points to top of multi-line fluent chain', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + '', + 'const cache = builder', + ' .addRedis("cache")', + ' .withLifetime("persistent");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].range.start.line, 3, '.addRedis is on line 3'); + assert.strictEqual(resources[0].statementStartLine, 2, 'statement starts on line 2 (const cache = builder)'); + }); + + test('statementStartLine works with multiple multi-line resources', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + '', + 'const cache = builder', + ' .addRedis("cache");', + '', + 'const db = builder', + ' .addPostgres("postgres");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources[0].statementStartLine, 2, 'cache starts at const cache'); + assert.strictEqual(resources[1].statementStartLine, 5, 'postgres starts at const db'); + }); + + test('statementStartLine skips single-line comments above statement', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + '', + '// ── Python Player ──────────────', + '// A cunning Python player', + 'const pythonPlayer = await builder', + ' .addPythonApp("python-player", "./python-player", "app.py")', + ' .withHttpEndpoint({ env: "PORT" });', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].statementStartLine, 4, 'statement starts at const pythonPlayer, skipping comments'); + }); + + test('statementStartLine skips block comments above statement', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + '', + '/* Multi-line', + ' * block comment', + ' */', + 'const cache = await builder', + ' .addRedis("cache");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].statementStartLine, 5, 'statement starts at const cache, skipping block comment'); + }); + + // --- parseResources: empty / no matches --- + + test('returns empty array for file with no add* calls', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nconst builder = createBuilder();', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0); + }); + + test('returns empty array for empty document', () => { + const parser = getJsTsParser(); + const doc = createMockDocument('', '/test/empty.ts'); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0); + }); + + // --- parseResources: edge cases --- + + test('does not match non-add methods', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'builder.withReference("notaresource");\nbuilder.configureOpenTelemetry("otel");', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0); + }); + + test('matches add* calls in commented-out code (known regex limitation)', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + '// builder.addRedis("commented-cache");', + '/* builder.addPostgres("block-commented"); */', + 'builder.addRedis("real-cache");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + // Regex-based parser cannot distinguish comments from code — all three match + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[2].name, 'real-cache'); + }); + + test('does not match template literal arguments', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'builder.addRedis(`cache`);', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0, 'Template literals should not match'); + }); + + test('range end position is correct', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'builder.addRedis("cache"', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + // .addRedis("cache" = 17 chars starting at index 7, so end = 7 + 17 = 24 + assert.strictEqual(resources[0].range.end.line, 0); + assert.strictEqual(resources[0].range.end.character, 24); + }); + + test('parses resource names with hyphens and underscores', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'builder.addRedis("my-cache");', + 'builder.addPostgres("my_db");', + 'builder.addRabbitMQ("event-bus-01");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[0].name, 'my-cache'); + assert.strictEqual(resources[1].name, 'my_db'); + assert.strictEqual(resources[2].name, 'event-bus-01'); + }); + + test('case-insensitive match for add* methods', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'builder.AddRedis("upper");\nbuilder.addRedis("lower");', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + // Both should match because JS/TS regex uses /gi flag + assert.strictEqual(resources.length, 2); + assert.strictEqual(resources[0].name, 'upper'); + assert.strictEqual(resources[1].name, 'lower'); + }); + + test('does not match mismatched quotes', () => { + const parser = getJsTsParser(); + // Mismatched quotes should NOT be parsed (the regex requires matching quote chars) + const doc = createMockDocument( + 'builder.addRedis("cache\');', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 0); + }); + + test('parses .js file correctly', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'const { createBuilder } = require("@aspire/sdk");', + 'const builder = createBuilder();', + 'builder.addRedis("cache");', + 'builder.addPostgres("db");', + ].join('\n'), + '/test/apphost.js' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 2); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[1].name, 'db'); + }); + + test('parses realistic full AppHost TS file', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + '', + 'const builder = createBuilder();', + '', + 'const cache = builder.addRedis("cache");', + '', + 'const db = builder.addPostgres("postgres")', + ' .addDatabase("catalogdb");', + '', + 'const api = builder.addProject("catalogapi")', + ' .withReference(cache)', + ' .withReference(db);', + '', + 'builder.addProject("webfrontend")', + ' .withExternalHttpEndpoints()', + ' .withReference(api);', + '', + 'builder.build().run();', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 5); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[1].name, 'postgres'); + assert.strictEqual(resources[2].name, 'catalogdb'); + assert.strictEqual(resources[3].name, 'catalogapi'); + assert.strictEqual(resources[4].name, 'webfrontend'); + + // All should be classified as resources + for (const r of resources) { + assert.strictEqual(r.kind, 'resource'); + } + }); + + // --- Pipeline step classification --- + + test('classifies addStep as pipelineStep', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nbuilder.pipeline.addStep("deploy-step", async (ctx) => { });', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].name, 'deploy-step'); + assert.strictEqual(resources[0].methodName, 'addStep'); + assert.strictEqual(resources[0].kind, 'pipelineStep'); + }); + + test('classifies addRedis as resource, not pipelineStep', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nbuilder.addRedis("cache");', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].kind, 'resource'); + }); + + test('classifies AddStep case-insensitively as pipelineStep', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + 'import { createBuilder } from "@aspire/sdk";\nbuilder.pipeline.AddStep("my-step", async (ctx) => { });', + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 1); + assert.strictEqual(resources[0].kind, 'pipelineStep'); + }); + + test('parses mixed resources and pipeline steps', () => { + const parser = getJsTsParser(); + const doc = createMockDocument( + [ + 'import { createBuilder } from "@aspire/sdk";', + 'const cache = builder.addRedis("cache");', + 'builder.pipeline.addStep("deploy", async (ctx) => { });', + 'const db = builder.addPostgres("pg");', + ].join('\n'), + '/test/apphost.ts' + ); + const resources = parser.parseResources(doc); + assert.strictEqual(resources.length, 3); + assert.strictEqual(resources[0].kind, 'resource'); + assert.strictEqual(resources[0].name, 'cache'); + assert.strictEqual(resources[1].kind, 'pipelineStep'); + assert.strictEqual(resources[1].name, 'deploy'); + assert.strictEqual(resources[2].kind, 'resource'); + assert.strictEqual(resources[2].name, 'pg'); + }); +}); diff --git a/extension/src/test/resourceStateUtils.test.ts b/extension/src/test/resourceStateUtils.test.ts new file mode 100644 index 00000000000..010c6743ef6 --- /dev/null +++ b/extension/src/test/resourceStateUtils.test.ts @@ -0,0 +1,177 @@ +import * as assert from 'assert'; +import { findResourceState, findWorkspaceResourceState, ResourceMatch } from '../editor/resourceStateUtils'; +import type { ResourceJson, AppHostDisplayInfo } from '../views/AppHostDataRepository'; +import { ResourceState } from '../editor/resourceConstants'; + +function makeResource(overrides: Partial = {}): ResourceJson { + return { + name: 'my-service', + displayName: null, + resourceType: 'Project', + state: null, + stateStyle: null, + healthStatus: null, + dashboardUrl: null, + urls: null, + commands: null, + properties: null, + ...overrides, + } as ResourceJson; +} + +function makeAppHost(overrides: Partial = {}): AppHostDisplayInfo { + return { + appHostPath: '/test/AppHost.csproj', + appHostPid: 1234, + cliPid: null, + dashboardUrl: null, + resources: null, + ...overrides, + } as AppHostDisplayInfo; +} + +suite('findResourceState', () => { + test('returns undefined when no appHosts provided', () => { + const result = findResourceState([], 'cache'); + assert.strictEqual(result, undefined); + }); + + test('returns undefined when appHosts have no resources', () => { + const appHost = makeAppHost({ resources: null }); + const result = findResourceState([appHost], 'cache'); + assert.strictEqual(result, undefined); + }); + + test('returns undefined when appHosts have empty resources', () => { + const appHost = makeAppHost({ resources: [] }); + const result = findResourceState([appHost], 'cache'); + assert.strictEqual(result, undefined); + }); + + test('matches resource by name', () => { + const resource = makeResource({ name: 'cache', displayName: null }); + const appHost = makeAppHost({ resources: [resource] }); + const result = findResourceState([appHost], 'cache'); + assert.ok(result); + assert.strictEqual(result!.resource, resource); + assert.strictEqual(result!.appHost, appHost); + }); + + test('matches resource by displayName', () => { + const resource = makeResource({ name: 'cache-abc123', displayName: 'cache' }); + const appHost = makeAppHost({ resources: [resource] }); + const result = findResourceState([appHost], 'cache'); + assert.ok(result); + assert.strictEqual(result!.resource, resource); + }); + + test('prefers displayName match over name match', () => { + const resource = makeResource({ name: 'cache-abc123', displayName: 'cache' }); + const appHost = makeAppHost({ resources: [resource] }); + // Searching by displayName should find it + const result = findResourceState([appHost], 'cache'); + assert.ok(result); + assert.strictEqual(result!.resource.displayName, 'cache'); + }); + + test('returns undefined when resource name does not match', () => { + const resource = makeResource({ name: 'redis', displayName: 'redis' }); + const appHost = makeAppHost({ resources: [resource] }); + const result = findResourceState([appHost], 'cache'); + assert.strictEqual(result, undefined); + }); + + test('searches across multiple appHosts', () => { + const resource1 = makeResource({ name: 'cache', displayName: 'cache' }); + const resource2 = makeResource({ name: 'db', displayName: 'db' }); + const appHost1 = makeAppHost({ appHostPid: 1, resources: [resource1] }); + const appHost2 = makeAppHost({ appHostPid: 2, resources: [resource2] }); + + const result = findResourceState([appHost1, appHost2], 'db'); + assert.ok(result); + assert.strictEqual(result!.resource, resource2); + assert.strictEqual(result!.appHost, appHost2); + }); + + test('returns first match when name exists in multiple appHosts', () => { + const resource1 = makeResource({ name: 'cache', state: ResourceState.Running }); + const resource2 = makeResource({ name: 'cache', state: ResourceState.Stopped }); + const appHost1 = makeAppHost({ appHostPid: 1, resources: [resource1] }); + const appHost2 = makeAppHost({ appHostPid: 2, resources: [resource2] }); + + const result = findResourceState([appHost1, appHost2], 'cache'); + assert.ok(result); + assert.strictEqual(result!.resource.state, ResourceState.Running); + }); + + test('skips appHosts with null resources', () => { + const resource = makeResource({ name: 'cache' }); + const appHost1 = makeAppHost({ appHostPid: 1, resources: null }); + const appHost2 = makeAppHost({ appHostPid: 2, resources: [resource] }); + + const result = findResourceState([appHost1, appHost2], 'cache'); + assert.ok(result); + assert.strictEqual(result!.appHost, appHost2); + }); +}); + +suite('findWorkspaceResourceState', () => { + test('returns undefined when no workspace resources', () => { + const finder = findWorkspaceResourceState([], '/test/path'); + const result = finder('cache'); + assert.strictEqual(result, undefined); + }); + + test('matches resource by name', () => { + const resource = makeResource({ name: 'cache' }); + const finder = findWorkspaceResourceState([resource], '/test/AppHost.csproj'); + const result = finder('cache'); + assert.ok(result); + assert.strictEqual(result!.resource, resource); + assert.strictEqual(result!.appHost.appHostPath, '/test/AppHost.csproj'); + }); + + test('matches resource by displayName', () => { + const resource = makeResource({ name: 'cache-xyz', displayName: 'cache' }); + const finder = findWorkspaceResourceState([resource], '/test/AppHost.csproj'); + const result = finder('cache'); + assert.ok(result); + assert.strictEqual(result!.resource, resource); + }); + + test('returns undefined when no match found', () => { + const resource = makeResource({ name: 'db' }); + const finder = findWorkspaceResourceState([resource], '/test/AppHost.csproj'); + const result = finder('cache'); + assert.strictEqual(result, undefined); + }); + + test('returned appHost has expected default values', () => { + const resource = makeResource({ name: 'cache' }); + const finder = findWorkspaceResourceState([resource], '/test/AppHost.csproj'); + const result = finder('cache'); + assert.ok(result); + assert.strictEqual(result!.appHost.appHostPid, 0); + assert.strictEqual(result!.appHost.cliPid, null); + assert.strictEqual(result!.appHost.dashboardUrl, null); + }); + + test('returned appHost resources is a copy', () => { + const resource = makeResource({ name: 'cache' }); + const resources = [resource]; + const finder = findWorkspaceResourceState(resources, '/test/AppHost.csproj'); + const result = finder('cache'); + assert.ok(result); + assert.notStrictEqual(result!.appHost.resources, resources); + assert.deepStrictEqual(result!.appHost.resources, resources); + }); + + test('can be called multiple times with different names', () => { + const r1 = makeResource({ name: 'cache' }); + const r2 = makeResource({ name: 'db' }); + const finder = findWorkspaceResourceState([r1, r2], '/test/AppHost.csproj'); + assert.ok(finder('cache')); + assert.ok(finder('db')); + assert.strictEqual(finder('nonexistent'), undefined); + }); +}); diff --git a/extension/src/views/AspireAppHostTreeProvider.ts b/extension/src/views/AspireAppHostTreeProvider.ts index fd1c4738e24..dccb5afb5e6 100644 --- a/extension/src/views/AspireAppHostTreeProvider.ts +++ b/extension/src/views/AspireAppHostTreeProvider.ts @@ -1,5 +1,6 @@ import * as vscode from 'vscode'; import { AspireTerminalProvider } from '../utils/AspireTerminalProvider'; +import { ResourceState, HealthStatus, StateStyle } from '../editor/resourceConstants'; import { pidDescription, dashboardLabel, @@ -20,10 +21,11 @@ import { AppHostDataRepository, AppHostDisplayInfo, ResourceJson, + ViewMode, shortenPath, } from './AppHostDataRepository'; -type TreeElement = AppHostItem | DetailItem | PidItem | EndpointUrlItem | ResourcesGroupItem | ResourceItem | WorkspaceResourcesItem; +type TreeElement = AppHostItem | PidItem | EndpointUrlItem | ResourcesGroupItem | ResourceItem | WorkspaceResourcesItem; function sortResources(resources: ResourceJson[]): ResourceJson[] { return [...resources].sort((a, b) => { @@ -65,15 +67,6 @@ class WorkspaceResourcesItem extends vscode.TreeItem { } } -class DetailItem extends vscode.TreeItem { - constructor(label: string, icon: string, tooltip?: string, command?: vscode.Command) { - super(label, vscode.TreeItemCollapsibleState.None); - this.iconPath = new vscode.ThemeIcon(icon); - this.tooltip = tooltip; - this.command = command; - } -} - class PidItem extends vscode.TreeItem { constructor(public readonly pid: number, label: string, icon: string) { super(label, vscode.TreeItemCollapsibleState.None); @@ -146,29 +139,29 @@ export function getResourceIcon(resource: ResourceJson): vscode.ThemeIcon { const state = resource.state; const health = resource.healthStatus; switch (state) { - case 'Running': - case 'Active': - if (health === 'Unhealthy' || resource.stateStyle === 'error') { + case ResourceState.Running: + case ResourceState.Active: + if (health === HealthStatus.Unhealthy || resource.stateStyle === StateStyle.Error) { return new vscode.ThemeIcon('error', new vscode.ThemeColor('list.errorForeground')); } - if (health === 'Degraded' || resource.stateStyle === 'warning') { + if (health === HealthStatus.Degraded || resource.stateStyle === StateStyle.Warning) { return new vscode.ThemeIcon('warning', new vscode.ThemeColor('list.warningForeground')); } return new vscode.ThemeIcon('pass', new vscode.ThemeColor('testing.iconPassed')); - case 'Finished': - case 'Exited': - if (resource.stateStyle === 'error') { + case ResourceState.Finished: + case ResourceState.Exited: + if (resource.stateStyle === StateStyle.Error) { return new vscode.ThemeIcon('error', new vscode.ThemeColor('list.errorForeground')); } return new vscode.ThemeIcon('circle-outline'); - case 'FailedToStart': - case 'RuntimeUnhealthy': + case ResourceState.FailedToStart: + case ResourceState.RuntimeUnhealthy: return new vscode.ThemeIcon('error', new vscode.ThemeColor('list.errorForeground')); - case 'Starting': - case 'Stopping': - case 'Building': - case 'Waiting': - case 'NotStarted': + case ResourceState.Starting: + case ResourceState.Stopping: + case ResourceState.Building: + case ResourceState.Waiting: + case ResourceState.NotStarted: return new vscode.ThemeIcon('loading~spin'); default: if (state === null || state === undefined) { @@ -218,11 +211,72 @@ export class AspireAppHostTreeProvider implements vscode.TreeDataProvider 0) { + const found = this._findResourceInTree(children, resourceName); + if (found) { + return found; + } + } + } + return undefined; + } + + getParent(element: TreeElement): TreeElement | undefined { + // Resolve ancestry so TreeView.reveal() can expand the correct path. + return this._findParent(this.getChildren(), element); + } + + private _findParent(siblings: TreeElement[], target: TreeElement): TreeElement | undefined { + for (const sibling of siblings) { + const children = this.getChildren(sibling); + for (const child of children) { + if (child.id === target.id) { + return sibling; + } + } + const deeper = this._findParent(children, target); + if (deeper) { + return deeper; + } + } + return undefined; + } + getTreeItem(element: TreeElement): vscode.TreeItem { return element; } @@ -278,7 +332,7 @@ export class AspireAppHostTreeProvider implements vscode.TreeDataProvider getParentResourceName(r) === element.resource.name); for (const child of sortResources(children)) { const hasChildren = allResources.some(r => getParentResourceName(r) === child.name); items.push(new ResourceItem(child, element.appHostPid, hasChildren)); } - // Add URL children - items.push(...this._getUrlChildren(element)); + const urls = element.resource.urls?.filter(u => !u.isInternal) ?? []; + items.push(...urls.map(url => new EndpointUrlItem(url.url, url.displayName ?? url.url))); return items; } - private _getUrlChildren(element: ResourceItem): TreeElement[] { - const urls = element.resource.urls?.filter(u => !u.isInternal) ?? []; - return urls.map(url => new EndpointUrlItem(url.url, url.displayName ?? url.url)); - } - // ── Commands ── openDashboard(element?: TreeElement): void { diff --git a/playground/TypeScriptApps/RpsArena/.modules/aspire.ts b/playground/TypeScriptApps/RpsArena/.modules/aspire.ts index 4c4f32ec54e..db541760c5e 100644 --- a/playground/TypeScriptApps/RpsArena/.modules/aspire.ts +++ b/playground/TypeScriptApps/RpsArena/.modules/aspire.ts @@ -4585,6 +4585,15 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -4697,7 +4706,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4727,7 +4736,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4773,7 +4782,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4826,7 +4835,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -4841,7 +4850,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5103,6 +5112,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -5464,7 +5478,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -5479,7 +5493,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -6034,7 +6048,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new ContainerResource(result, this._client); @@ -6049,7 +6063,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new ContainerResource(result, this._client); @@ -6191,41 +6205,11 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -6236,43 +6220,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -6678,7 +6657,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -6708,7 +6687,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -6754,7 +6733,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -6859,7 +6838,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -6890,7 +6869,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -6905,7 +6884,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -7335,31 +7314,21 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -7784,41 +7753,11 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -7829,43 +7768,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -8256,7 +8190,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8286,7 +8220,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8316,7 +8250,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8362,7 +8296,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8467,7 +8401,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8498,7 +8432,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8513,7 +8447,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8854,31 +8788,21 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -9406,41 +9330,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -9451,43 +9345,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -9893,7 +9782,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -9923,7 +9812,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -9969,7 +9858,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10074,7 +9963,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10105,7 +9994,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10120,7 +10009,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10496,31 +10385,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -10953,41 +10832,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -10998,43 +10847,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -11440,7 +11284,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -11470,7 +11314,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -11516,7 +11360,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -11621,7 +11465,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -11652,7 +11496,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -11667,7 +11511,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12013,31 +11857,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -12538,7 +12372,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -12553,7 +12387,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -13102,41 +12936,11 @@ export class JavaScriptAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new JavaScriptAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new JavaScriptAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -13147,43 +12951,38 @@ export class JavaScriptAppResource extends ResourceBuilderBase Promise): JavaScriptAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { return new JavaScriptAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new JavaScriptAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new JavaScriptAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -13619,7 +13418,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -13649,7 +13448,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -13695,7 +13494,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -13800,7 +13599,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -13831,7 +13630,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -13846,7 +13645,7 @@ export class JavaScriptAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new JavaScriptAppResource(result, this._client); @@ -14321,31 +14120,21 @@ export class JavaScriptAppResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): JavaScriptAppResourcePromise { - return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): JavaScriptAppResourcePromise { return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): JavaScriptAppResourcePromise { + return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): JavaScriptAppResourcePromise { return new JavaScriptAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -14853,41 +14642,11 @@ export class NodeAppResource extends ResourceBuilderBase } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new NodeAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new NodeAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -14898,43 +14657,38 @@ export class NodeAppResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { return new NodeAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new NodeAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new NodeAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -15325,7 +15079,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new NodeAppResource(result, this._client); @@ -15385,7 +15139,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new NodeAppResource(result, this._client); @@ -15415,7 +15169,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new NodeAppResource(result, this._client); @@ -15461,7 +15215,7 @@ export class NodeAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new NodeAppResource(result, this._client); @@ -15566,7 +15320,7 @@ export class NodeAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new NodeAppResource(result, this._client); @@ -15597,7 +15351,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new NodeAppResource(result, this._client); @@ -15612,7 +15366,7 @@ export class NodeAppResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new NodeAppResource(result, this._client); @@ -16087,31 +15841,21 @@ export class NodeAppResourcePromise implements PromiseLike { return new NodeAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): NodeAppResourcePromise { - return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): NodeAppResourcePromise { return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): NodeAppResourcePromise { + return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): NodeAppResourcePromise { return new NodeAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -16660,7 +16404,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -16675,7 +16419,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -17235,7 +16979,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -17250,7 +16994,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -17392,41 +17136,11 @@ export class PgAdminContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new PgAdminContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new PgAdminContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -17437,43 +17151,38 @@ export class PgAdminContainerResource extends ResourceBuilderBase Promise): PgAdminContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { return new PgAdminContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new PgAdminContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new PgAdminContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -17879,7 +17588,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -17909,7 +17618,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -17955,7 +17664,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -18060,7 +17769,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -18091,7 +17800,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -18106,7 +17815,7 @@ export class PgAdminContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new PgAdminContainerResource(result, this._client); @@ -18553,31 +18262,21 @@ export class PgAdminContainerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgAdminContainerResourcePromise { - return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgAdminContainerResourcePromise { return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PgAdminContainerResourcePromise { + return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): PgAdminContainerResourcePromise { return new PgAdminContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -19061,7 +18760,7 @@ export class PgWebContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -19076,7 +18775,7 @@ export class PgWebContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -19218,41 +18917,11 @@ export class PgWebContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new PgWebContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -19263,43 +18932,38 @@ export class PgWebContainerResource extends ResourceBuilderBase Promise): PgWebContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { return new PgWebContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new PgWebContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new PgWebContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -19705,7 +19369,7 @@ export class PgWebContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -19735,7 +19399,7 @@ export class PgWebContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -19781,7 +19445,7 @@ export class PgWebContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -19886,7 +19550,7 @@ export class PgWebContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -19917,7 +19581,7 @@ export class PgWebContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -19932,7 +19596,7 @@ export class PgWebContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new PgWebContainerResource(result, this._client); @@ -20379,31 +20043,21 @@ export class PgWebContainerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PgWebContainerResourcePromise { - return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PgWebContainerResourcePromise { return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PgWebContainerResourcePromise { + return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): PgWebContainerResourcePromise { return new PgWebContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -20822,6 +20476,15 @@ export class PostgresDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -20986,7 +20649,7 @@ export class PostgresDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new PostgresDatabaseResource(result, this._client); @@ -21001,7 +20664,7 @@ export class PostgresDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new PostgresDatabaseResource(result, this._client); @@ -21302,6 +20965,11 @@ export class PostgresDatabaseResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): PostgresDatabaseResourcePromise { return new PostgresDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -21640,7 +21308,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -21655,7 +21323,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -21797,41 +21465,11 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new PostgresMcpContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new PostgresMcpContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -21842,43 +21480,38 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase Promise): PostgresMcpContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -22284,7 +21917,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -22314,7 +21947,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -22360,7 +21993,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -22465,7 +22098,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -22496,7 +22129,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -22511,7 +22144,7 @@ export class PostgresMcpContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new PostgresMcpContainerResource(result, this._client); @@ -22941,31 +22574,21 @@ export class PostgresMcpContainerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresMcpContainerResourcePromise { - return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PostgresMcpContainerResourcePromise { + return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): PostgresMcpContainerResourcePromise { return new PostgresMcpContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -23595,7 +23218,7 @@ export class PostgresServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -23610,7 +23233,7 @@ export class PostgresServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -23752,41 +23375,11 @@ export class PostgresServerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new PostgresServerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new PostgresServerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -23797,43 +23390,38 @@ export class PostgresServerResource extends ResourceBuilderBase Promise): PostgresServerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new PostgresServerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -23972,6 +23560,15 @@ export class PostgresServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withReferenceUriInternal(name: string, uri: string): Promise { const rpcArgs: Record = { builder: this._handle, name, uri }; @@ -24269,7 +23866,7 @@ export class PostgresServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -24299,7 +23896,7 @@ export class PostgresServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -24345,7 +23942,7 @@ export class PostgresServerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -24450,7 +24047,7 @@ export class PostgresServerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -24481,7 +24078,7 @@ export class PostgresServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -24496,7 +24093,7 @@ export class PostgresServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new PostgresServerResource(result, this._client); @@ -25109,31 +24706,21 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PostgresServerResourcePromise { - return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PostgresServerResourcePromise { + return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -25174,6 +24761,11 @@ export class PostgresServerResourcePromise implements PromiseLike obj.withReference(source, options))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): PostgresServerResourcePromise { return new PostgresServerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -25618,41 +25210,11 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -25663,43 +25225,38 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -26090,7 +25647,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -26120,7 +25677,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -26150,7 +25707,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -26196,7 +25753,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -26301,7 +25858,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -26332,7 +25889,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -26347,7 +25904,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -26688,31 +26245,21 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -27150,41 +26697,11 @@ export class PythonAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new PythonAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PythonAppResourcePromise { - return new PythonAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new PythonAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PythonAppResourcePromise { - return new PythonAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -27195,43 +26712,38 @@ export class PythonAppResource extends ResourceBuilderBase Promise): PythonAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PythonAppResourcePromise { return new PythonAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new PythonAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PythonAppResourcePromise { - return new PythonAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PythonAppResourcePromise { + return new PythonAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new PythonAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PythonAppResourcePromise { - return new PythonAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PythonAppResourcePromise { + return new PythonAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -27622,7 +27134,7 @@ export class PythonAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new PythonAppResource(result, this._client); @@ -27652,7 +27164,7 @@ export class PythonAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new PythonAppResource(result, this._client); @@ -27682,7 +27194,7 @@ export class PythonAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new PythonAppResource(result, this._client); @@ -27728,7 +27240,7 @@ export class PythonAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new PythonAppResource(result, this._client); @@ -27833,7 +27345,7 @@ export class PythonAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new PythonAppResource(result, this._client); @@ -27864,7 +27376,7 @@ export class PythonAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new PythonAppResource(result, this._client); @@ -27879,7 +27391,7 @@ export class PythonAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new PythonAppResource(result, this._client); @@ -28310,31 +27822,21 @@ export class PythonAppResourcePromise implements PromiseLike return new PythonAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): PythonAppResourcePromise { - return new PythonAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): PythonAppResourcePromise { - return new PythonAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): PythonAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): PythonAppResourcePromise { return new PythonAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): PythonAppResourcePromise { - return new PythonAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): PythonAppResourcePromise { return new PythonAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): PythonAppResourcePromise { + return new PythonAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): PythonAppResourcePromise { return new PythonAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -28838,7 +28340,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -28853,7 +28355,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -28995,41 +28497,11 @@ export class RedisCommanderResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -29040,43 +28512,38 @@ export class RedisCommanderResource extends ResourceBuilderBase Promise): RedisCommanderResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -29482,7 +28949,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -29512,7 +28979,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -29558,7 +29025,7 @@ export class RedisCommanderResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -29663,7 +29130,7 @@ export class RedisCommanderResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -29694,7 +29161,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -29709,7 +29176,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -30156,31 +29623,21 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -30664,7 +30121,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -30679,7 +30136,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -30821,41 +30278,11 @@ export class RedisInsightResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -30866,43 +30293,38 @@ export class RedisInsightResource extends ResourceBuilderBase Promise): RedisInsightResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -31308,7 +30730,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -31338,7 +30760,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -31384,7 +30806,7 @@ export class RedisInsightResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -31489,7 +30911,7 @@ export class RedisInsightResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -31520,7 +30942,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -31535,7 +30957,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -32014,31 +31436,21 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -32648,7 +32060,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', + 'Aspire.Hosting/withParameterBuildArg', rpcArgs ); return new RedisResource(result, this._client); @@ -32663,7 +32075,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisResource(result, this._client); @@ -32805,41 +32217,11 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -32850,43 +32232,38 @@ export class RedisResource extends ResourceBuilderBase { } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { return new RedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -33025,6 +32402,15 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withReferenceUriInternal(name: string, uri: string): Promise { const rpcArgs: Record = { builder: this._handle, name, uri }; @@ -33322,7 +32708,7 @@ export class RedisResource extends ResourceBuilderBase { private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisResource(result, this._client); @@ -33352,7 +32738,7 @@ export class RedisResource extends ResourceBuilderBase { private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisResource(result, this._client); @@ -33398,7 +32784,7 @@ export class RedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisResource(result, this._client); @@ -33503,7 +32889,7 @@ export class RedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisResource(result, this._client); @@ -33534,7 +32920,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisResource(result, this._client); @@ -33549,7 +32935,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisResource(result, this._client); @@ -34134,31 +33520,21 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -34199,6 +33575,11 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -34646,41 +34027,11 @@ export class UvicornAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new UvicornAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): UvicornAppResourcePromise { - return new UvicornAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new UvicornAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): UvicornAppResourcePromise { - return new UvicornAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -34691,43 +34042,38 @@ export class UvicornAppResource extends ResourceBuilderBase Promise): UvicornAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): UvicornAppResourcePromise { return new UvicornAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new UvicornAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): UvicornAppResourcePromise { - return new UvicornAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): UvicornAppResourcePromise { + return new UvicornAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new UvicornAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): UvicornAppResourcePromise { - return new UvicornAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): UvicornAppResourcePromise { + return new UvicornAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -35118,7 +34464,7 @@ export class UvicornAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new UvicornAppResource(result, this._client); @@ -35148,7 +34494,7 @@ export class UvicornAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new UvicornAppResource(result, this._client); @@ -35178,7 +34524,7 @@ export class UvicornAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new UvicornAppResource(result, this._client); @@ -35224,7 +34570,7 @@ export class UvicornAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new UvicornAppResource(result, this._client); @@ -35329,7 +34675,7 @@ export class UvicornAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new UvicornAppResource(result, this._client); @@ -35360,7 +34706,7 @@ export class UvicornAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new UvicornAppResource(result, this._client); @@ -35375,7 +34721,7 @@ export class UvicornAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new UvicornAppResource(result, this._client); @@ -35806,31 +35152,21 @@ export class UvicornAppResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): UvicornAppResourcePromise { - return new UvicornAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): UvicornAppResourcePromise { - return new UvicornAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): UvicornAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): UvicornAppResourcePromise { return new UvicornAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): UvicornAppResourcePromise { - return new UvicornAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): UvicornAppResourcePromise { return new UvicornAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): UvicornAppResourcePromise { + return new UvicornAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): UvicornAppResourcePromise { return new UvicornAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -36323,41 +35659,11 @@ export class ViteAppResource extends ResourceBuilderBase } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ViteAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ViteAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -36368,43 +35674,38 @@ export class ViteAppResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { return new ViteAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ViteAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ViteAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -36840,7 +36141,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ViteAppResource(result, this._client); @@ -36870,7 +36171,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ViteAppResource(result, this._client); @@ -36916,7 +36217,7 @@ export class ViteAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ViteAppResource(result, this._client); @@ -37021,7 +36322,7 @@ export class ViteAppResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ViteAppResource(result, this._client); @@ -37052,7 +36353,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ViteAppResource(result, this._client); @@ -37067,7 +36368,7 @@ export class ViteAppResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ViteAppResource(result, this._client); @@ -37557,31 +36858,21 @@ export class ViteAppResourcePromise implements PromiseLike { return new ViteAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ViteAppResourcePromise { - return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ViteAppResourcePromise { + return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ViteAppResourcePromise { return new ViteAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -37970,7 +37261,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -38229,7 +37520,7 @@ export class Resource extends ResourceBuilderBase { private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -38244,7 +37535,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -38720,6 +38011,15 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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) => { @@ -38767,6 +38067,11 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Subscribes to the ConnectionStringAvailable event */ onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); @@ -39194,41 +38499,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -39239,43 +38514,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -39409,7 +38679,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -39463,31 +38733,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -39553,7 +38813,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -39583,7 +38843,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -39614,7 +38874,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); diff --git a/playground/TypeScriptApps/RpsArena/.modules/transport.ts b/playground/TypeScriptApps/RpsArena/.modules/transport.ts index 904e57142f9..6d29cf289d9 100644 --- a/playground/TypeScriptApps/RpsArena/.modules/transport.ts +++ b/playground/TypeScriptApps/RpsArena/.modules/transport.ts @@ -830,7 +830,7 @@ export class AspireClient { failConnect(new Error('Connection closed before JSON-RPC was established')); }; - const onConnect = () => { + const onConnect = async () => { if (settled) { return; } @@ -867,7 +867,16 @@ export class AspireClient { 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; diff --git a/playground/TypeScriptApps/RpsArena/apphost.ts b/playground/TypeScriptApps/RpsArena/apphost.ts index cb317f12160..b0eb4a5695d 100644 --- a/playground/TypeScriptApps/RpsArena/apphost.ts +++ b/playground/TypeScriptApps/RpsArena/apphost.ts @@ -11,6 +11,7 @@ const builder = await createBuilder(); const postgres = await builder .addPostgres("postgres") .withLifetime(ContainerLifetime.Persistent) + .withPgAdmin() .withDataVolume(); const gameDb = await postgres.addDatabase("gamedb"); diff --git a/playground/TypeScriptApps/RpsArena/aspire.config.json b/playground/TypeScriptApps/RpsArena/aspire.config.json new file mode 100644 index 00000000000..7bcdb1ba8f6 --- /dev/null +++ b/playground/TypeScriptApps/RpsArena/aspire.config.json @@ -0,0 +1,14 @@ +{ + "appHost": { + "path": "apphost.ts" + }, + "profiles": { + "https": { + "applicationUrl": "https://rpsarena.dev.localhost:16323;http://rpsarena.dev.localhost:15163", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://rpsarena.dev.localhost:35807", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://rpsarena.dev.localhost:32833" + } + } + } +} From 896182eb8ebb93cc39046088d41c524d7e8506e7 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Thu, 19 Mar 2026 23:22:44 +0000 Subject: [PATCH 24/49] [release/13.2] Stabilize Aspire.Hosting.Docker package (#15377) * Stabilize Aspire.Hosting.Docker package Remove SuppressFinalPackageVersion to make the package ship as a stable release. Add DisablePackageBaselineValidation since this is the first stable version and there is no prior baseline to validate against. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix tests for stable version --------- Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Eric Erhardt --- src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj | 2 +- tests/Shared/RepoTesting/Directory.Packages.Helix.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj b/src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj index cb998ff2da8..c490263a37b 100644 --- a/src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj +++ b/src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj @@ -3,7 +3,7 @@ $(DefaultTargetFramework) true - true + true aspire hosting docker docker-compose Docker Compose publishing for Aspire. true diff --git a/tests/Shared/RepoTesting/Directory.Packages.Helix.props b/tests/Shared/RepoTesting/Directory.Packages.Helix.props index dbeeab88840..27b52defa1e 100644 --- a/tests/Shared/RepoTesting/Directory.Packages.Helix.props +++ b/tests/Shared/RepoTesting/Directory.Packages.Helix.props @@ -35,7 +35,7 @@ - + From e44e59b344b50af6c547801a7a64f3bedd8f20af Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Thu, 19 Mar 2026 20:02:53 -0400 Subject: [PATCH 25/49] Fix dashboard image in marketplace README and bump version to 1.0.6 (#15379) --- extension/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/README.md b/extension/README.md index 4da192931d9..cf6ec5065d8 100644 --- a/extension/README.md +++ b/extension/README.md @@ -135,7 +135,7 @@ Right-click a resource to start, stop, or restart it, view its logs, run resourc The dashboard gives you a live view of your running app — all your resources and their health, endpoint URLs, console logs from every service, structured logs (via OpenTelemetry), distributed traces across services, and metrics. -![Aspire Dashboard showing running resources](resources/aspire-dashboard-dark.png) +![Aspire Dashboard showing running resources](https://raw.githubusercontent.com/dotnet/aspire/main/extension/resources/aspire-dashboard-dark.png) It opens automatically when you start your app. You can pick which browser it uses with the `aspire.dashboardBrowser` setting — system default browser, or Chrome, Edge, or Firefox as a debug session. When using a debug browser, the `aspire.closeDashboardOnDebugEnd` setting controls whether it closes automatically when you stop debugging. Firefox also requires the [Firefox Debugger](https://marketplace.visualstudio.com/items?itemName=firefox-devtools.vscode-firefox-debug) extension. From 652e35f4ff6872894fcb76c70fc93297a18e2a6a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:55:48 -0700 Subject: [PATCH 26/49] Fix default NuGet packages restore folder (#15417) We shouldn't default to ~/.nuget/packages. Instead we should use NuGet defaulting logic. Fix #15404 Co-authored-by: Eric Erhardt --- src/Aspire.Managed/NuGet/Commands/RestoreCommand.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Aspire.Managed/NuGet/Commands/RestoreCommand.cs b/src/Aspire.Managed/NuGet/Commands/RestoreCommand.cs index 0507b06af52..72e11447ef0 100644 --- a/src/Aspire.Managed/NuGet/Commands/RestoreCommand.cs +++ b/src/Aspire.Managed/NuGet/Commands/RestoreCommand.cs @@ -144,9 +144,8 @@ private static async Task ExecuteRestoreAsync( var outputPath = Path.GetFullPath(output); Directory.CreateDirectory(outputPath); - packagesDir ??= Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), - ".nuget", "packages"); + var settings = Settings.LoadDefaultSettings(workingDir, nugetConfigPath, new XPlatMachineWideSetting()); + packagesDir ??= SettingsUtility.GetGlobalPackagesFolder(settings); var logger = new NuGetLogger(verbose); From 84563b3204747513de4e06ff16df41911d5ce661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 19 Mar 2026 19:56:39 -0700 Subject: [PATCH 27/49] [release/13.2] Store temporary AppHost service under user .aspire directory (#15415) * [release/13.2] Store temporary AppHost service under user .aspire directory Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * [release/13.2] Address PR review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../DotNetBasedAppHostServerProject.cs | 16 +----- .../Projects/PrebuiltAppHostServer.cs | 2 +- .../Projects/AppHostServerProjectTests.cs | 35 +++++++++++++ .../Projects/PrebuiltAppHostServerTests.cs | 49 ++++++++++++++++++- 4 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs b/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs index 484a2da84bb..9b9663ba0f4 100644 --- a/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs +++ b/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs @@ -22,7 +22,6 @@ namespace Aspire.Cli.Projects; internal sealed class DotNetBasedAppHostServerProject : IAppHostServerProject { private const string ProjectHashFileName = ".projecthash"; - private const string FolderPrefix = ".aspire"; private const string AppsFolder = "hosts"; public const string ProjectFileName = "AppHostServer.csproj"; private const string ProjectDllName = "AppHostServer.dll"; @@ -74,20 +73,7 @@ public DotNetBasedAppHostServerProject( else { var pathDir = Convert.ToHexString(pathHash)[..12].ToLowerInvariant(); - var tempPath = Path.GetTempPath(); - // On macOS, /var is a symlink to /private/var. MSBuild resolves symlinks when - // computing relative paths between projects, but then tries to resolve those - // relative paths from the original (unresolved) directory. This mismatch causes - // transitive project references to fail. Using the canonical path ensures consistency. - if (OperatingSystem.IsMacOS() && tempPath.StartsWith("/var/", StringComparison.Ordinal)) - { - var canonical = "/private" + tempPath; - if (Directory.Exists(canonical)) - { - tempPath = canonical; - } - } - _projectModelPath = Path.Combine(tempPath, FolderPrefix, AppsFolder, pathDir); + _projectModelPath = Path.Combine(CliPathHelper.GetAspireHomeDirectory(), AppsFolder, pathDir); } // Create a stable UserSecretsId based on the app path hash diff --git a/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs b/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs index d263b743db1..5c05e2a66d7 100644 --- a/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs +++ b/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs @@ -74,7 +74,7 @@ public PrebuiltAppHostServer( // Create a working directory for this app host session var pathHash = SHA256.HashData(Encoding.UTF8.GetBytes(_appDirectoryPath)); var pathDir = Convert.ToHexString(pathHash)[..12].ToLowerInvariant(); - _workingDirectory = Path.Combine(Path.GetTempPath(), ".aspire", "bundle-hosts", pathDir); + _workingDirectory = Path.Combine(CliPathHelper.GetAspireHomeDirectory(), "bundle-hosts", pathDir); Directory.CreateDirectory(_workingDirectory); } diff --git a/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs b/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs index 2deebbb0aca..89ac6a12b2b 100644 --- a/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs @@ -2,11 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.InternalTesting; +using System.Security.Cryptography; +using System.Text; using System.Xml.Linq; using Aspire.Cli.Configuration; using Aspire.Cli.NuGet; using Aspire.Cli.Packaging; using Aspire.Cli.Projects; +using Aspire.Cli.Utils; using Aspire.Cli.Tests.Mcp; using Aspire.Cli.Tests.TestServices; using Aspire.Cli.Tests.Utils; @@ -186,6 +189,38 @@ public void ProjectModelPath_IsStableForSameAppPath() Assert.Equal(project1.ProjectModelPath, project2.ProjectModelPath); } + [Fact] + public void ProjectModelPath_UsesUserAspireDirectory() + { + // Arrange + var project = CreateProject(); + var normalizedAppPath = Path.GetFullPath(project.AppDirectoryPath); + normalizedAppPath = new Uri(normalizedAppPath).LocalPath; + normalizedAppPath = OperatingSystem.IsWindows() ? normalizedAppPath.ToLowerInvariant() : normalizedAppPath; + + var pathHash = SHA256.HashData(Encoding.UTF8.GetBytes(normalizedAppPath)); + var pathDir = Convert.ToHexString(pathHash)[..12].ToLowerInvariant(); + var expectedRoot = Path.Combine(CliPathHelper.GetAspireHomeDirectory(), "hosts"); + var expectedPath = Path.Combine(expectedRoot, pathDir); + var parentDirectory = Path.GetDirectoryName(project.ProjectModelPath); + var isSafeToDelete = string.Equals(project.ProjectModelPath, expectedPath, StringComparison.OrdinalIgnoreCase) && + parentDirectory is not null && + string.Equals(parentDirectory, expectedRoot, StringComparison.OrdinalIgnoreCase); + + try + { + // Assert + Assert.Equal(expectedPath, project.ProjectModelPath); + } + finally + { + if (isSafeToDelete && Directory.Exists(project.ProjectModelPath)) + { + Directory.Delete(project.ProjectModelPath, recursive: true); + } + } + } + [Fact] public void UserSecretsId_IsStableForSameAppPath() { diff --git a/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs b/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs index d659bb978d0..8888eff0583 100644 --- a/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs @@ -3,11 +3,16 @@ using System.Xml.Linq; using Aspire.Cli.Configuration; +using Aspire.Cli.Layout; +using Aspire.Cli.NuGet; using Aspire.Cli.Projects; +using Aspire.Cli.Tests.TestServices; +using Aspire.Cli.Tests.Utils; +using Aspire.Cli.Utils; namespace Aspire.Cli.Tests.Projects; -public class PrebuiltAppHostServerTests +public class PrebuiltAppHostServerTests(ITestOutputHelper outputHelper) { [Fact] public void GenerateIntegrationProjectFile_WithPackagesOnly_ProducesPackageReferences() @@ -145,4 +150,46 @@ public void GenerateIntegrationProjectFile_WithEmptyAdditionalSources_DoesNotSet Assert.Null(restoreSources); } + [Fact] + public void Constructor_UsesUserAspireDirectoryForWorkingDirectory() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var nugetService = new BundleNuGetService(new NullLayoutDiscovery(), Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance); + var server = new PrebuiltAppHostServer( + workspace.WorkspaceRoot.FullName, + "test.sock", + new LayoutConfiguration(), + nugetService, + new TestDotNetCliRunner(), + new TestDotNetSdkInstaller(), + new Aspire.Cli.Tests.Mcp.MockPackagingService(), + new TestConfigurationService(), + Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance); + + var workingDirectory = Assert.IsType( + typeof(PrebuiltAppHostServer) + .GetField("_workingDirectory", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)! + .GetValue(server)); + + var rootDirectory = Path.Combine(CliPathHelper.GetAspireHomeDirectory(), "bundle-hosts"); + var isUnderRoot = workingDirectory.StartsWith(rootDirectory, StringComparison.OrdinalIgnoreCase); + var parentDirectory = Path.GetDirectoryName(workingDirectory); + var isDirectChildOfRoot = parentDirectory is not null && + string.Equals(parentDirectory, rootDirectory, StringComparison.OrdinalIgnoreCase); + var isSafeToDelete = isUnderRoot && isDirectChildOfRoot && !string.Equals(workingDirectory, rootDirectory, StringComparison.OrdinalIgnoreCase); + + try + { + Assert.True(isSafeToDelete); + } + finally + { + if (isSafeToDelete && Directory.Exists(workingDirectory)) + { + Directory.Delete(workingDirectory, recursive: true); + } + } + } + } From aad16017893bd769e0634c47fb007f1454735f11 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Fri, 20 Mar 2026 02:56:59 +0000 Subject: [PATCH 28/49] Fix crash when reading boolean config values from aspire.config.json (#15383) When 'aspire config set features.X true' writes a JSON string "true" instead of a JSON boolean, AspireConfigFile.Load() fails to deserialize the Dictionary Features property. Fix by adding a FlexibleBooleanConverter that tolerates both JSON booleans and JSON string representations of booleans. The converter is registered globally via JsonSourceGenerationOptions.Converters so all bool properties benefit. Also fix TryNormalizeSettingsFile to use DeepClone() instead of ToString() when normalizing colon-separated keys, which was corrupting non-string types. Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Configuration/FlexibleBooleanConverter.cs | 42 +++++++++++++ src/Aspire.Cli/JsonSourceGenerationContext.cs | 3 +- src/Aspire.Cli/Utils/ConfigurationHelper.cs | 6 +- .../Configuration/AspireConfigFileTests.cs | 63 +++++++++++++++++++ .../Configuration/ConfigurationHelperTests.cs | 33 ++++++++++ .../ConfigurationServiceTests.cs | 62 ++++++++++++++++++ 6 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 src/Aspire.Cli/Configuration/FlexibleBooleanConverter.cs diff --git a/src/Aspire.Cli/Configuration/FlexibleBooleanConverter.cs b/src/Aspire.Cli/Configuration/FlexibleBooleanConverter.cs new file mode 100644 index 00000000000..5e75f0d04d3 --- /dev/null +++ b/src/Aspire.Cli/Configuration/FlexibleBooleanConverter.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Aspire.Cli.Configuration; + +/// +/// A JSON converter for that accepts both actual boolean values +/// (true/false) and string representations ("true"/"false"). +/// This provides backward compatibility for settings files that may have string values +/// written by older CLI versions. +/// +internal sealed class FlexibleBooleanConverter : JsonConverter +{ + public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + return reader.TokenType switch + { + JsonTokenType.True => true, + JsonTokenType.False => false, + JsonTokenType.String => ParseString(reader.GetString()), + _ => throw new JsonException($"Unexpected token parsing boolean. Token: {reader.TokenType}") + }; + } + + private static bool ParseString(string? value) + { + if (bool.TryParse(value, out var result)) + { + return result; + } + + throw new JsonException($"Invalid boolean value: '{value}'. Expected 'true' or 'false'."); + } + + public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) + { + writer.WriteBooleanValue(value); + } +} diff --git a/src/Aspire.Cli/JsonSourceGenerationContext.cs b/src/Aspire.Cli/JsonSourceGenerationContext.cs index ad23050e888..b0fadbcf717 100644 --- a/src/Aspire.Cli/JsonSourceGenerationContext.cs +++ b/src/Aspire.Cli/JsonSourceGenerationContext.cs @@ -18,7 +18,8 @@ namespace Aspire.Cli; WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, AllowTrailingCommas = true, - ReadCommentHandling = JsonCommentHandling.Skip)] + ReadCommentHandling = JsonCommentHandling.Skip, + Converters = [typeof(FlexibleBooleanConverter)])] [JsonSerializable(typeof(CliSettings))] [JsonSerializable(typeof(JsonObject))] [JsonSerializable(typeof(ListIntegrationsResponse))] diff --git a/src/Aspire.Cli/Utils/ConfigurationHelper.cs b/src/Aspire.Cli/Utils/ConfigurationHelper.cs index 8d4e4b2235f..354a0bb0696 100644 --- a/src/Aspire.Cli/Utils/ConfigurationHelper.cs +++ b/src/Aspire.Cli/Utils/ConfigurationHelper.cs @@ -154,13 +154,15 @@ internal static bool TryNormalizeSettingsFile(string filePath) } // Find all colon-separated keys at root level - var colonKeys = new List<(string key, string? value)>(); + var colonKeys = new List<(string key, JsonNode? value)>(); foreach (var kvp in settings) { if (kvp.Key.Contains(':')) { - colonKeys.Add((kvp.Key, kvp.Value?.ToString())); + // DeepClone preserves the original JSON type (boolean, number, etc.) + // instead of converting to string via ToString(). + colonKeys.Add((kvp.Key, kvp.Value?.DeepClone())); } } diff --git a/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs b/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs index ec3d9c4d6f6..f7556f11b89 100644 --- a/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs +++ b/tests/Aspire.Cli.Tests/Configuration/AspireConfigFileTests.cs @@ -306,6 +306,69 @@ public void GetIntegrationReferences_IncludesPackagesAndBasePackage() Assert.Contains(refs, r => r.Name == "Aspire.Hosting.Redis"); } + [Fact] + public void Load_ReturnsConfig_WhenFeaturesAreBooleans() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var configPath = Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); + File.WriteAllText(configPath, """ + { + "features": { "polyglotSupportEnabled": true, "showAllTemplates": false } + } + """); + + var result = AspireConfigFile.Load(workspace.WorkspaceRoot.FullName); + + Assert.NotNull(result); + Assert.NotNull(result.Features); + Assert.True(result.Features["polyglotSupportEnabled"]); + Assert.False(result.Features["showAllTemplates"]); + } + + [Fact] + public void Load_ReturnsConfig_WhenFeaturesAreStringBooleans() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + // Simulates what happens when ConfigurationService.SetNestedValue wrote "true"/"false" as strings + var configPath = Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); + File.WriteAllText(configPath, """ + { + "features": { "polyglotSupportEnabled": "true", "showAllTemplates": "false" } + } + """); + + var result = AspireConfigFile.Load(workspace.WorkspaceRoot.FullName); + + Assert.NotNull(result); + Assert.NotNull(result.Features); + Assert.True(result.Features["polyglotSupportEnabled"]); + Assert.False(result.Features["showAllTemplates"]); + } + + [Fact] + public void Save_Load_RoundTrips_WithFeatures() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var config = new AspireConfigFile + { + Features = new Dictionary + { + ["polyglotSupportEnabled"] = true, + ["showAllTemplates"] = false + } + }; + + config.Save(workspace.WorkspaceRoot.FullName); + var loaded = AspireConfigFile.Load(workspace.WorkspaceRoot.FullName); + + Assert.NotNull(loaded?.Features); + Assert.True(loaded.Features["polyglotSupportEnabled"]); + Assert.False(loaded.Features["showAllTemplates"]); + } + [Fact] public void Load_RoundTrips_WithProfiles() { diff --git a/tests/Aspire.Cli.Tests/Configuration/ConfigurationHelperTests.cs b/tests/Aspire.Cli.Tests/Configuration/ConfigurationHelperTests.cs index cdea30079d2..f65125ca022 100644 --- a/tests/Aspire.Cli.Tests/Configuration/ConfigurationHelperTests.cs +++ b/tests/Aspire.Cli.Tests/Configuration/ConfigurationHelperTests.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Text.Json; +using System.Text.Json.Nodes; using Aspire.Cli.Configuration; using Aspire.Cli.Tests.Utils; using Aspire.Cli.Utils; @@ -108,4 +110,35 @@ public void RegisterSettingsFiles_HandlesCommentsAndTrailingCommas() Assert.Equal("MyApp.csproj", config["appHost:path"]); Assert.Equal("daily", config["channel"]); } + + [Fact] + public void TryNormalizeSettingsFile_PreservesBooleanTypes() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var settingsPath = Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); + // File has a colon-separated key with a boolean value + File.WriteAllText(settingsPath, """ + { + "features:polyglotSupportEnabled": true, + "features:showAllTemplates": false + } + """); + + var normalized = ConfigurationHelper.TryNormalizeSettingsFile(settingsPath); + + Assert.True(normalized); + + var json = JsonNode.Parse(File.ReadAllText(settingsPath)); + var polyglotNode = json!["features"]!["polyglotSupportEnabled"]; + var templatesNode = json!["features"]!["showAllTemplates"]; + Assert.Equal(JsonValueKind.True, polyglotNode!.GetValueKind()); + Assert.Equal(JsonValueKind.False, templatesNode!.GetValueKind()); + + // Verify the file can be loaded by AspireConfigFile without error + var config = AspireConfigFile.Load(workspace.WorkspaceRoot.FullName); + Assert.NotNull(config?.Features); + Assert.True(config.Features["polyglotSupportEnabled"]); + Assert.False(config.Features["showAllTemplates"]); + } } diff --git a/tests/Aspire.Cli.Tests/Configuration/ConfigurationServiceTests.cs b/tests/Aspire.Cli.Tests/Configuration/ConfigurationServiceTests.cs index 8b10267db2b..f0ff9161d10 100644 --- a/tests/Aspire.Cli.Tests/Configuration/ConfigurationServiceTests.cs +++ b/tests/Aspire.Cli.Tests/Configuration/ConfigurationServiceTests.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Text.Json; +using System.Text.Json.Nodes; using Aspire.Cli.Configuration; using Aspire.Cli.Tests.Utils; using Microsoft.Extensions.Configuration; @@ -225,4 +227,64 @@ public async Task SetConfigurationAsync_SetsNestedValues() Assert.Contains("appHost", result); Assert.Contains("MyApp/MyApp.csproj", result); } + + [Fact] + public async Task SetConfigurationAsync_WritesBooleanStringAsJsonString() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var (service, settingsFilePath) = CreateService(workspace, "{}"); + + await service.SetConfigurationAsync("features.polyglotSupportEnabled", "true", isGlobal: false); + + // Value is written as a JSON string "true", not a JSON boolean true. + // The FlexibleBooleanConverter handles parsing "true" -> bool on read. + var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); + var node = json!["features"]!["polyglotSupportEnabled"]; + Assert.Equal(JsonValueKind.String, node!.GetValueKind()); + Assert.Equal("true", node.GetValue()); + + // Verify round-trip through AspireConfigFile.Load still works + var config = AspireConfigFile.Load(workspace.WorkspaceRoot.FullName); + Assert.NotNull(config?.Features); + Assert.True(config.Features["polyglotSupportEnabled"]); + } + + [Fact] + public async Task SetConfigurationAsync_ChannelWithBooleanLikeValue_StaysAsString() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var (service, settingsFilePath) = CreateService(workspace, "{}"); + + // "true" is a valid channel value and must remain a string in JSON + // to avoid corrupting the string-typed Channel property. + await service.SetConfigurationAsync("channel", "true", isGlobal: false); + + // Must be a JSON string "true", not a JSON boolean true + var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); + var node = json!["channel"]; + Assert.Equal(JsonValueKind.String, node!.GetValueKind()); + Assert.Equal("true", node.GetValue()); + + // Verify it round-trips correctly through AspireConfigFile.Load + var config = AspireConfigFile.Load(workspace.WorkspaceRoot.FullName); + Assert.NotNull(config); + Assert.Equal("true", config.Channel); + } + + [Fact] + public async Task SetConfigurationAsync_WritesStringValueAsString() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var (service, settingsFilePath) = CreateService(workspace, "{}"); + + await service.SetConfigurationAsync("channel", "daily", isGlobal: false); + + var json = JsonNode.Parse(File.ReadAllText(settingsFilePath)); + var node = json!["channel"]; + Assert.Equal(JsonValueKind.String, node!.GetValueKind()); + Assert.Equal("daily", node.GetValue()); + } } From e8bb0079a170fad5acc4095f026d5ba829f0b575 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Fri, 20 Mar 2026 17:06:49 +0000 Subject: [PATCH 29/49] Fix config discovery to search from apphost directory and add aspire.config.json to .NET templates (#15423) * Add E2E test: config discovery from apphost directory Adds a test that verifies aspire.config.json is discovered adjacent to the apphost file when running from a parent directory, rather than being recreated in the current working directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix config discovery to search from apphost directory When an apphost is found via recursive search, use its directory as the search root for aspire.config.json (walking upward) instead of defaulting to CWD. This prevents creating a duplicate config when the user runs 'aspire run' from a parent directory after 'aspire new'. Changes: - Add ConfigurationHelper.FindNearestConfigFilePath helper - ProjectLocator.CreateSettingsFileAsync: skip creation when config already exists near the apphost with valid appHost.path - GuestAppHostProject.GetConfigDirectory: search from apphost directory so launch profiles are read from the correct config Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix: only skip config creation when path matches discovered apphost The previous check skipped creation whenever any appHost.path existed, which broke config healing when the path was stale/invalid. Now we resolve the stored path and only skip if it points to the same apphost that was discovered via recursive search. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add aspire.config.json to .NET apphost templates Include aspire.config.json with appHost.path in the aspire-apphost (csproj) and aspire-apphost-singlefile templates so that aspire run from a parent directory finds the config adjacent to the apphost instead of creating a spurious one in the working directory. The csproj template uses sourceName 'Aspire.AppHost1' so the template engine substitutes the actual project name automatically. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add aspire.config.json to solution-level apphost templates Add aspire.config.json at the solution root for aspire-empty, aspire-starter, and aspire-ts-cs-starter templates. Each points to the AppHost csproj via a relative path. The template engine substitutes the sourceName so the path matches the actual project name chosen by the user. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add aspire.config.json to aspire-py-starter template Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review feedback: fix legacy path handling, stale docs, dead code - Fix legacy .aspire/settings.json path handling in ProjectLocator: resolve config root to parent of .aspire/ directory - Update GetConfigDirectory XML doc to reflect new behavior - Remove unused _configurationService field and constructor parameter - Assert originalContent == currentContent in E2E test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Projects/GuestAppHostProject.cs | 35 ++-- src/Aspire.Cli/Projects/ProjectLocator.cs | 41 +++++ src/Aspire.Cli/Utils/ConfigurationHelper.cs | 28 ++++ .../aspire.config.json | 5 + .../aspire-apphost/aspire.config.json | 5 + .../templates/aspire-empty/aspire.config.json | 5 + .../aspire-py-starter/aspire.config.json | 5 + .../aspire-starter/aspire.config.json | 5 + .../aspire-ts-cs-starter/aspire.config.json | 5 + .../ConfigDiscoveryTests.cs | 149 ++++++++++++++++++ .../Projects/GuestAppHostProjectTests.cs | 12 +- 11 files changed, 266 insertions(+), 29 deletions(-) create mode 100644 src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/aspire.config.json create mode 100644 src/Aspire.ProjectTemplates/templates/aspire-apphost/aspire.config.json create mode 100644 src/Aspire.ProjectTemplates/templates/aspire-empty/aspire.config.json create mode 100644 src/Aspire.ProjectTemplates/templates/aspire-py-starter/aspire.config.json create mode 100644 src/Aspire.ProjectTemplates/templates/aspire-starter/aspire.config.json create mode 100644 src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/aspire.config.json create mode 100644 tests/Aspire.Cli.EndToEnd.Tests/ConfigDiscoveryTests.cs diff --git a/src/Aspire.Cli/Projects/GuestAppHostProject.cs b/src/Aspire.Cli/Projects/GuestAppHostProject.cs index 74c16ceda2a..9800c782a5c 100644 --- a/src/Aspire.Cli/Projects/GuestAppHostProject.cs +++ b/src/Aspire.Cli/Projects/GuestAppHostProject.cs @@ -37,7 +37,6 @@ internal sealed class GuestAppHostProject : IAppHostProject, IGuestAppHostSdkGen private readonly IDotNetCliRunner _runner; private readonly IPackagingService _packagingService; private readonly IConfiguration _configuration; - private readonly IConfigurationService _configurationService; private readonly IFeatures _features; private readonly ILanguageDiscovery _languageDiscovery; private readonly ILogger _logger; @@ -58,7 +57,6 @@ public GuestAppHostProject( IDotNetCliRunner runner, IPackagingService packagingService, IConfiguration configuration, - IConfigurationService configurationService, IFeatures features, ILanguageDiscovery languageDiscovery, ILogger logger, @@ -73,7 +71,6 @@ public GuestAppHostProject( _runner = runner; _packagingService = packagingService; _configuration = configuration; - _configurationService = configurationService; _features = features; _languageDiscovery = languageDiscovery; _logger = logger; @@ -167,27 +164,27 @@ private async Task> GetIntegrationReferencesAsync( /// /// Resolves the directory containing the nearest aspire.config.json (or legacy settings file) - /// by using the already-resolved path from . + /// by searching upward from . /// Falls back to when no config file is found. /// - private DirectoryInfo GetConfigDirectory(DirectoryInfo appHostDirectory) + private static DirectoryInfo GetConfigDirectory(DirectoryInfo appHostDirectory) { - var settingsFilePath = _configurationService.GetSettingsFilePath(isGlobal: false); - var settingsFile = new FileInfo(settingsFilePath); - - // If the settings file exists and has a parent directory, use that - if (settingsFile.Directory is { Exists: true }) + // Search from the apphost's directory upward to find the nearest config file. + var nearAppHost = ConfigurationHelper.FindNearestConfigFilePath(appHostDirectory); + if (nearAppHost is not null) { - // For legacy .aspire/settings.json, the config directory is the parent of .aspire/ - // TODO: Remove legacy .aspire/ check once confident most users have migrated. - // Tracked by https://github.com/dotnet/aspire/issues/15239 - if (string.Equals(settingsFile.Directory.Name, ".aspire", StringComparison.OrdinalIgnoreCase) - && settingsFile.Directory.Parent is not null) + var configFile = new FileInfo(nearAppHost); + if (configFile.Directory is { Exists: true }) { - return settingsFile.Directory.Parent; - } + // For legacy .aspire/settings.json, the config directory is the parent of .aspire/ + if (string.Equals(configFile.Directory.Name, ".aspire", StringComparison.OrdinalIgnoreCase) + && configFile.Directory.Parent is not null) + { + return configFile.Directory.Parent; + } - return settingsFile.Directory; + return configFile.Directory; + } } return appHostDirectory; @@ -209,7 +206,7 @@ private AspireConfigFile LoadConfiguration(DirectoryInfo directory) } } - private void SaveConfiguration(AspireConfigFile config, DirectoryInfo directory) + private static void SaveConfiguration(AspireConfigFile config, DirectoryInfo directory) { var configDir = GetConfigDirectory(directory); config.Save(configDir.FullName); diff --git a/src/Aspire.Cli/Projects/ProjectLocator.cs b/src/Aspire.Cli/Projects/ProjectLocator.cs index 8a89c49de30..cae79274ce0 100644 --- a/src/Aspire.Cli/Projects/ProjectLocator.cs +++ b/src/Aspire.Cli/Projects/ProjectLocator.cs @@ -401,6 +401,47 @@ public async Task UseOrFindAppHostProjectFileAsync(F private async Task CreateSettingsFileAsync(FileInfo projectFile, CancellationToken cancellationToken) { + // Search from the apphost's directory upward for an existing config file. + // This handles the case where "aspire new" created a project in a subdirectory + // and the user runs "aspire run" from the parent without cd-ing first. + if (projectFile.Directory is { } appHostDir) + { + var nearAppHost = ConfigurationHelper.FindNearestConfigFilePath(appHostDir); + if (nearAppHost is not null) + { + var configDir = Path.GetDirectoryName(nearAppHost)!; + + // For legacy .aspire/settings.json, the config root is the parent of .aspire/ + var trimmedConfigDir = configDir.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + if (string.Equals(Path.GetFileName(trimmedConfigDir), ".aspire", StringComparison.OrdinalIgnoreCase)) + { + var parentDir = Directory.GetParent(trimmedConfigDir); + if (parentDir is not null) + { + configDir = parentDir.FullName; + } + } + + var existingConfig = AspireConfigFile.Load(configDir); + if (existingConfig?.AppHost?.Path is { } existingPath) + { + // Resolve the stored path relative to the config file's directory. + var resolvedPath = Path.GetFullPath( + Path.IsPathRooted(existingPath) ? existingPath : Path.Combine(configDir, existingPath)); + + // Only skip creation if the config already points to the discovered apphost. + // If the path is stale/invalid, fall through so the config gets healed. + if (string.Equals(resolvedPath, projectFile.FullName, StringComparison.OrdinalIgnoreCase)) + { + logger.LogDebug( + "Config at {Path} already references apphost {AppHost}, skipping creation", + nearAppHost, projectFile.FullName); + return; + } + } + } + } + var settingsFile = GetOrCreateLocalAspireConfigFile(); var fileExisted = settingsFile.Exists; diff --git a/src/Aspire.Cli/Utils/ConfigurationHelper.cs b/src/Aspire.Cli/Utils/ConfigurationHelper.cs index 354a0bb0696..1034cada776 100644 --- a/src/Aspire.Cli/Utils/ConfigurationHelper.cs +++ b/src/Aspire.Cli/Utils/ConfigurationHelper.cs @@ -69,6 +69,34 @@ internal static string BuildPathToSettingsJsonFile(string workingDirectory) return Path.Combine(workingDirectory, ".aspire", "settings.json"); } + /// + /// Searches upward from for the nearest + /// aspire.config.json or legacy .aspire/settings.json. + /// + /// The full path to the config file, or null if none is found. + internal static string? FindNearestConfigFilePath(DirectoryInfo startDirectory) + { + var searchDir = startDirectory; + while (searchDir is not null) + { + var configPath = Path.Combine(searchDir.FullName, AspireConfigFile.FileName); + if (File.Exists(configPath)) + { + return configPath; + } + + var legacyPath = BuildPathToSettingsJsonFile(searchDir.FullName); + if (File.Exists(legacyPath)) + { + return legacyPath; + } + + searchDir = searchDir.Parent; + } + + return null; + } + /// /// Serializes a JsonObject and writes it to a settings file, creating the directory if needed. /// diff --git a/src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/aspire.config.json b/src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/aspire.config.json new file mode 100644 index 00000000000..a777aa51fac --- /dev/null +++ b/src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/aspire.config.json @@ -0,0 +1,5 @@ +{ + "appHost": { + "path": "apphost.cs" + } +} diff --git a/src/Aspire.ProjectTemplates/templates/aspire-apphost/aspire.config.json b/src/Aspire.ProjectTemplates/templates/aspire-apphost/aspire.config.json new file mode 100644 index 00000000000..00d04809d13 --- /dev/null +++ b/src/Aspire.ProjectTemplates/templates/aspire-apphost/aspire.config.json @@ -0,0 +1,5 @@ +{ + "appHost": { + "path": "Aspire.AppHost1.csproj" + } +} diff --git a/src/Aspire.ProjectTemplates/templates/aspire-empty/aspire.config.json b/src/Aspire.ProjectTemplates/templates/aspire-empty/aspire.config.json new file mode 100644 index 00000000000..2af258e560b --- /dev/null +++ b/src/Aspire.ProjectTemplates/templates/aspire-empty/aspire.config.json @@ -0,0 +1,5 @@ +{ + "appHost": { + "path": "AspireApplication.1.AppHost/AspireApplication.1.AppHost.csproj" + } +} diff --git a/src/Aspire.ProjectTemplates/templates/aspire-py-starter/aspire.config.json b/src/Aspire.ProjectTemplates/templates/aspire-py-starter/aspire.config.json new file mode 100644 index 00000000000..a777aa51fac --- /dev/null +++ b/src/Aspire.ProjectTemplates/templates/aspire-py-starter/aspire.config.json @@ -0,0 +1,5 @@ +{ + "appHost": { + "path": "apphost.cs" + } +} diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/aspire.config.json b/src/Aspire.ProjectTemplates/templates/aspire-starter/aspire.config.json new file mode 100644 index 00000000000..0f24fea7e44 --- /dev/null +++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/aspire.config.json @@ -0,0 +1,5 @@ +{ + "appHost": { + "path": "Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj" + } +} diff --git a/src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/aspire.config.json b/src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/aspire.config.json new file mode 100644 index 00000000000..0f24fea7e44 --- /dev/null +++ b/src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/aspire.config.json @@ -0,0 +1,5 @@ +{ + "appHost": { + "path": "Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj" + } +} diff --git a/tests/Aspire.Cli.EndToEnd.Tests/ConfigDiscoveryTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/ConfigDiscoveryTests.cs new file mode 100644 index 00000000000..d7d5f1b7a0f --- /dev/null +++ b/tests/Aspire.Cli.EndToEnd.Tests/ConfigDiscoveryTests.cs @@ -0,0 +1,149 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json; +using Aspire.Cli.EndToEnd.Tests.Helpers; +using Aspire.Cli.Tests.Utils; +using Hex1b.Automation; +using Hex1b.Input; +using Xunit; + +namespace Aspire.Cli.EndToEnd.Tests; + +/// +/// End-to-end tests verifying that aspire.config.json is discovered from the +/// apphost's directory rather than being recreated in the current working directory. +/// +/// +/// Reproduces the bug where aspire new myproject creates the config inside +/// myproject/, but running aspire run from the parent directory +/// creates a spurious aspire.config.json in the parent instead of finding +/// the one adjacent to apphost.ts. +/// +public sealed class ConfigDiscoveryTests(ITestOutputHelper output) +{ + /// + /// Verifies that running aspire run from a parent directory discovers the + /// existing aspire.config.json next to the apphost rather than creating a + /// new one in the current working directory. + /// + [Fact] + public async Task RunFromParentDirectory_UsesExistingConfigNearAppHost() + { + var repoRoot = CliE2ETestHelpers.GetRepoRoot(); + var installMode = CliE2ETestHelpers.DetectDockerInstallMode(repoRoot); + var workspace = TemporaryWorkspace.Create(output); + + using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal( + repoRoot, installMode, output, + variant: CliE2ETestHelpers.DockerfileVariant.Polyglot, + mountDockerSocket: true, + workspace: workspace); + + var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken); + + var counter = new SequenceCounter(); + var auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500)); + + await auto.PrepareDockerEnvironmentAsync(counter, workspace); + await auto.InstallAspireCliInDockerAsync(installMode, counter); + + const string projectName = "ConfigTest"; + + // Step 1: Create a TypeScript Empty AppHost project. + // This creates a subdirectory with aspire.config.json inside it. + await auto.AspireNewAsync(projectName, counter, template: AspireTemplate.TypeScriptEmptyAppHost); + + // Capture the original config content before running from the parent directory. + var projectConfigPath = Path.Combine( + workspace.WorkspaceRoot.FullName, projectName, "aspire.config.json"); + var parentConfigPath = Path.Combine( + workspace.WorkspaceRoot.FullName, "aspire.config.json"); + + // Verify the project config was created by aspire new + Assert.True(File.Exists(projectConfigPath), + $"aspire new should have created {projectConfigPath}"); + + var originalContent = File.ReadAllText(projectConfigPath); + + // Step 2: Stay in the parent directory (do NOT cd into the project). + // Run aspire run — this should find the apphost in the subdirectory + // and use the adjacent aspire.config.json, not create a new one in CWD. + // Run aspire run — this should find the apphost in the subdirectory + // and use the adjacent aspire.config.json, not create a new one in CWD. + await auto.TypeAsync($"aspire run --apphost {projectName}"); + await auto.EnterAsync(); + + // Wait for the run to start (or fail) — either way the config discovery has happened. + await auto.WaitUntilAsync(s => + { + // If a "Select an apphost" prompt appears, the bug may have caused multiple detection + if (s.ContainsText("Select an apphost to use:")) + { + throw new InvalidOperationException("Multiple apphosts incorrectly detected"); + } + + return s.ContainsText("Press CTRL+C to stop the apphost and exit.") + || s.ContainsText("ERR:"); + }, timeout: TimeSpan.FromMinutes(3), description: "aspire run started or errored"); + + // Stop the apphost + await auto.Ctrl().KeyAsync(Hex1bKey.C); + await auto.WaitForAnyPromptAsync(counter, timeout: TimeSpan.FromSeconds(30)); + + // Step 3: Assertions on file system state (host-side via bind mount). + + // The parent directory should NOT have an aspire.config.json. + Assert.False(File.Exists(parentConfigPath), + $"aspire.config.json should NOT be created in the parent/CWD directory. " + + $"Found: {parentConfigPath}"); + + // The project's aspire.config.json should still exist with its original rich content. + Assert.True(File.Exists(projectConfigPath), + $"aspire.config.json in project directory should still exist: {projectConfigPath}"); + + var currentContent = File.ReadAllText(projectConfigPath); + + // Verify the config was not modified by the run. + Assert.Equal(originalContent, currentContent); + + using var doc = JsonDocument.Parse(currentContent); + var root = doc.RootElement; + + // Verify appHost.path is "apphost.ts" + Assert.True(root.TryGetProperty("appHost", out var appHost), + $"aspire.config.json missing 'appHost' property. Content:\n{currentContent}"); + Assert.True(appHost.TryGetProperty("path", out var pathProp), + $"aspire.config.json missing 'appHost.path'. Content:\n{currentContent}"); + Assert.Equal("apphost.ts", pathProp.GetString()); + + // Verify language is typescript + Assert.True(appHost.TryGetProperty("language", out var langProp), + $"aspire.config.json missing 'appHost.language'. Content:\n{currentContent}"); + Assert.Contains("typescript", langProp.GetString(), StringComparison.OrdinalIgnoreCase); + + // Verify profiles section exists with applicationUrl + Assert.True(root.TryGetProperty("profiles", out var profiles), + $"aspire.config.json missing 'profiles' section. Content:\n{currentContent}"); + Assert.True(profiles.EnumerateObject().Any(), + $"aspire.config.json 'profiles' section is empty. Content:\n{currentContent}"); + + // At least one profile should have an applicationUrl + var hasApplicationUrl = false; + foreach (var profile in profiles.EnumerateObject()) + { + if (profile.Value.TryGetProperty("applicationUrl", out _)) + { + hasApplicationUrl = true; + break; + } + } + Assert.True(hasApplicationUrl, + $"No profile has 'applicationUrl'. Content:\n{currentContent}"); + + await auto.TypeAsync("exit"); + await auto.EnterAsync(); + + await pendingRun; + } +} diff --git a/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs b/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs index 20f5f6f9765..0caee5d34db 100644 --- a/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs @@ -302,7 +302,7 @@ await Verify(content, extension: "json") [Fact] public void GetServerEnvironmentVariables_ParsesLaunchSettingsWithComments() { - var project = CreateGuestAppHostProject(_workspace.WorkspaceRoot); + var project = CreateGuestAppHostProject(); var propertiesDir = _workspace.CreateDirectory("Properties"); var launchSettingsPath = Path.Combine(propertiesDir.FullName, "launchSettings.json"); @@ -333,7 +333,7 @@ public void GetServerEnvironmentVariables_ParsesLaunchSettingsWithComments() Assert.False(envVars.ContainsKey("ASPIRE_DASHBOARD_OTLP_HTTP_ENDPOINT_URL")); } - private static GuestAppHostProject CreateGuestAppHostProject(DirectoryInfo workspaceRoot) + private static GuestAppHostProject CreateGuestAppHostProject() { var language = new LanguageInfo( LanguageId: "typescript/nodejs", @@ -342,13 +342,6 @@ private static GuestAppHostProject CreateGuestAppHostProject(DirectoryInfo works DetectionPatterns: ["apphost.ts"], CodeGenerator: "TypeScript"); - // Point the config service at a non-existent file so GetConfigDirectory - // falls back to the directory we pass to GetServerEnvironmentVariables. - var configService = new TestConfigurationService - { - SettingsFilePath = Path.Combine(workspaceRoot.FullName, "nonexistent", "settings.json") - }; - var configuration = new ConfigurationBuilder().Build(); var logFilePath = Path.Combine(Path.GetTempPath(), $"test-guest-{Guid.NewGuid()}.log"); @@ -362,7 +355,6 @@ private static GuestAppHostProject CreateGuestAppHostProject(DirectoryInfo works runner: new TestDotNetCliRunner(), packagingService: new TestPackagingService(), configuration: configuration, - configurationService: configService, features: new Features(configuration, NullLogger.Instance), languageDiscovery: new TestLanguageDiscovery(), logger: NullLogger.Instance, From 1b339b0aab41b049e8e0d21ed1a79596cf8b8509 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Fri, 20 Mar 2026 12:47:20 -0500 Subject: [PATCH 30/49] Fix Windows CLI backchannel socket path (#15444) * Fix Windows CLI backchannel socket path * Respond to PR feedback When using named pipes for the Guest AppHost, we need to just return a name, not a path. --- src/Aspire.Cli/DotNet/DotNetCliRunner.cs | 2 +- .../Projects/AppHostServerProject.cs | 2 +- .../Projects/GuestAppHostProject.cs | 2 +- src/Aspire.Cli/Utils/CliPathHelper.cs | 10 ++++++-- .../Utils/CliPathHelperTests.cs | 23 ++++++++++++++++--- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/Aspire.Cli/DotNet/DotNetCliRunner.cs b/src/Aspire.Cli/DotNet/DotNetCliRunner.cs index 9ddd56b189c..8ac6505d4ca 100644 --- a/src/Aspire.Cli/DotNet/DotNetCliRunner.cs +++ b/src/Aspire.Cli/DotNet/DotNetCliRunner.cs @@ -83,7 +83,7 @@ private string GetMsBuildServerValue() internal static string GetBackchannelSocketPath() { - return CliPathHelper.CreateSocketPath("cli.sock"); + return CliPathHelper.CreateUnixDomainSocketPath("cli.sock"); } private async Task ExecuteAsync( diff --git a/src/Aspire.Cli/Projects/AppHostServerProject.cs b/src/Aspire.Cli/Projects/AppHostServerProject.cs index d2c37cc2d5a..a0aacb7bef7 100644 --- a/src/Aspire.Cli/Projects/AppHostServerProject.cs +++ b/src/Aspire.Cli/Projects/AppHostServerProject.cs @@ -34,7 +34,7 @@ internal sealed class AppHostServerProjectFactory( { public async Task CreateAsync(string appPath, CancellationToken cancellationToken = default) { - var socketPath = CliPathHelper.CreateSocketPath("apphost.sock"); + var socketPath = CliPathHelper.CreateGuestAppHostSocketPath("apphost.sock"); // Priority 1: Check for dev mode (ASPIRE_REPO_ROOT or running from Aspire source repo) var repoRoot = AspireRepositoryDetector.DetectRepositoryRoot(appPath); diff --git a/src/Aspire.Cli/Projects/GuestAppHostProject.cs b/src/Aspire.Cli/Projects/GuestAppHostProject.cs index 9800c782a5c..1024b27398c 100644 --- a/src/Aspire.Cli/Projects/GuestAppHostProject.cs +++ b/src/Aspire.Cli/Projects/GuestAppHostProject.cs @@ -922,7 +922,7 @@ await GenerateCodeViaRpcAsync( /// private static string GetBackchannelSocketPath() { - return CliPathHelper.CreateSocketPath("cli.sock"); + return CliPathHelper.CreateUnixDomainSocketPath("cli.sock"); } /// diff --git a/src/Aspire.Cli/Utils/CliPathHelper.cs b/src/Aspire.Cli/Utils/CliPathHelper.cs index 46f87a397b2..48aedcb8e52 100644 --- a/src/Aspire.Cli/Utils/CliPathHelper.cs +++ b/src/Aspire.Cli/Utils/CliPathHelper.cs @@ -14,11 +14,17 @@ internal static string GetAspireHomeDirectory() /// Creates a randomized CLI-managed socket path. /// /// The socket file prefix. - internal static string CreateSocketPath(string socketPrefix) + internal static string CreateUnixDomainSocketPath(string socketPrefix) + => CreateSocketPath(socketPrefix, isGuestAppHost: false); + + internal static string CreateGuestAppHostSocketPath(string socketPrefix) + => CreateSocketPath(socketPrefix, isGuestAppHost: true); + + private static string CreateSocketPath(string socketPrefix, bool isGuestAppHost) { var socketName = $"{socketPrefix}.{BackchannelConstants.CreateRandomIdentifier()}"; - if (OperatingSystem.IsWindows()) + if (isGuestAppHost && OperatingSystem.IsWindows()) { return socketName; } diff --git a/tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs b/tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs index 5f31d7fa973..2c570508e98 100644 --- a/tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs +++ b/tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs @@ -8,12 +8,12 @@ namespace Aspire.Cli.Tests.Utils; public class CliPathHelperTests(ITestOutputHelper outputHelper) { [Fact] - public void CreateSocketPath_UsesRandomizedIdentifier() + public void CreateGuestAppHostSocketPath_UsesRandomizedIdentifier() { using var workspace = TemporaryWorkspace.Create(outputHelper); - var socketPath1 = CliPathHelper.CreateSocketPath("apphost.sock"); - var socketPath2 = CliPathHelper.CreateSocketPath("apphost.sock"); + var socketPath1 = CliPathHelper.CreateGuestAppHostSocketPath("apphost.sock"); + var socketPath2 = CliPathHelper.CreateGuestAppHostSocketPath("apphost.sock"); Assert.NotEqual(socketPath1, socketPath2); @@ -31,4 +31,21 @@ public void CreateSocketPath_UsesRandomizedIdentifier() Assert.Matches("^apphost\\.sock\\.[a-f0-9]{12}$", Path.GetFileName(socketPath2)); } } + + [Fact] + public void CreateUnixDomainSocketPath_UsesRandomizedIdentifier() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var socketPath1 = CliPathHelper.CreateUnixDomainSocketPath("apphost.sock"); + var socketPath2 = CliPathHelper.CreateUnixDomainSocketPath("apphost.sock"); + + Assert.NotEqual(socketPath1, socketPath2); + + var expectedDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".aspire", "cli", "runtime", "sockets"); + Assert.Equal(expectedDirectory, Path.GetDirectoryName(socketPath1)); + Assert.Equal(expectedDirectory, Path.GetDirectoryName(socketPath2)); + Assert.Matches("^apphost\\.sock\\.[a-f0-9]{12}$", Path.GetFileName(socketPath1)); + Assert.Matches("^apphost\\.sock\\.[a-f0-9]{12}$", Path.GetFileName(socketPath2)); + } } From 30d3d9727935d9089d6bc0a4fd40eac3d4ab04a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Sat, 21 Mar 2026 11:14:44 -0700 Subject: [PATCH 31/49] Update CI workflow owner guards and repo references from dotnet to microsoft (#15466) * Update all dotnet/aspire references to microsoft/aspire Updated all GitHub Actions workflow owner guards from repository_owner == 'dotnet' to repository_owner == 'microsoft' across 24 workflow files. Replaced all dotnet/aspire repository references with microsoft/aspire across 288 files including workflows, scripts, tests, READMEs, source code, templates, and documentation. Preserved aka.ms short links pointing to dotnet/aspire as those are external redirects. Fixed SigstoreNpmProvenanceCheckerTests expectedOwner to match the updated URL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use GitHub App token for PR creation in all workflows The microsoft org disables GITHUB_TOKEN from creating PRs. This updates all 10 workflows that create PRs to use a GitHub App installation token (via actions/create-github-app-token) instead. - 9 workflows: add app token step, pass to existing PR creation logic - backport: rewrite locally (arcade reusable workflow doesn't accept custom tokens), filed dotnet/arcade#16585 for upstream support - release-github-tasks: also fix head: -> branch: bug in PR creation Replicates changes from microsoft/aspire-internal-reorg-temp#10. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Apply remaining microsoft/aspire updates for release/13.2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Jose Perez Rodriguez Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/10_bug_report.yml | 4 +- .github/ISSUE_TEMPLATE/20_feature-request.yml | 2 +- .../ISSUE_TEMPLATE/40_blocking_clean_ci.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 2 +- .../client-readme.instructions.md | 12 +- .../hosting-readme.instructions.md | 4 +- .github/skills/ci-test-failures/SKILL.md | 18 +- .github/skills/cli-e2e-testing/SKILL.md | 4 +- .github/skills/dependency-update/SKILL.md | 2 +- .github/skills/pr-testing/SKILL.md | 18 +- .github/skills/test-management/SKILL.md | 24 +- .../skills/update-container-images/SKILL.md | 4 +- .github/workflows/README.md | 10 +- .github/workflows/apply-test-attributes.yml | 14 +- .../auto-rerun-transient-ci-failures.yml | 2 +- .github/workflows/backport.yml | 261 +++++++++++++++++- .github/workflows/ci.yml | 6 +- .../workflows/cli-e2e-recording-comment.yml | 2 +- .github/workflows/deployment-cleanup.yml | 2 +- .github/workflows/deployment-test-command.yml | 2 +- .github/workflows/deployment-tests.yml | 8 +- .github/workflows/dogfood-comment.yml | 6 +- .github/workflows/generate-api-diffs.yml | 11 +- .github/workflows/generate-ats-diffs.yml | 11 +- .github/workflows/labeler-cache-retention.yml | 2 +- .github/workflows/labeler-predict-issues.yml | 2 +- .github/workflows/labeler-predict-pulls.yml | 2 +- .github/workflows/locker.yml | 2 +- .github/workflows/markdownlint.yml | 2 +- .github/workflows/pr-docs-hook.yml | 6 +- .github/workflows/pr-review-needed.yml | 2 +- .github/workflows/refresh-manifests.yml | 11 +- .github/workflows/refresh-typescript-sdks.yml | 2 +- .github/workflows/release-github-tasks.yml | 31 ++- .github/workflows/specialized-test-runner.yml | 10 +- .github/workflows/tests-outerloop.yml | 2 +- .github/workflows/tests-quarantine.yml | 2 +- .github/workflows/tests.yml | 2 +- .../workflows/update-ai-foundry-models.yml | 11 +- .github/workflows/update-dependencies.yml | 11 +- .github/workflows/update-github-models.yml | 11 +- AGENTS.md | 20 +- Directory.Build.props | 8 +- README.md | 8 +- docs/area-owners.md | 30 +- docs/dogfooding-pull-requests.md | 8 +- docs/machine-requirements.md | 2 +- docs/quarantined-tests.md | 2 +- docs/release-process.md | 10 +- docs/specs/appmodel.md | 2 +- docs/specs/bundle.md | 2 +- docs/specs/dashboard-http-api.md | 4 +- docs/specs/polyglot-apphost-testing.md | 2 +- docs/specs/polyglot-apphost.md | 2 +- eng/Signing.props | 2 +- eng/pipelines/README.md | 2 +- eng/pipelines/release-publish-nuget.yml | 6 +- eng/pipelines/templates/BuildAndTest.yml | 2 +- eng/scripts/README.md | 6 +- eng/scripts/get-aspire-cli-pr.ps1 | 18 +- eng/scripts/get-aspire-cli-pr.sh | 14 +- eng/scripts/get-aspire-cli.ps1 | 2 +- eng/scripts/get-aspire-cli.sh | 4 +- eng/scripts/get-cli-e2e-recording.ps1 | 2 +- eng/scripts/get-cli-e2e-recording.sh | 2 +- .../Aspire.locale.en-US.yaml.template | 4 +- .../Aspire.locale.en-US.yaml.template | 4 +- extension/README.md | 8 +- extension/package.json | 4 +- .../api-roles-sql.module.bicep | 2 +- .../frontend/src/App.tsx | 2 +- .../ParameterEndToEnd.AppHost/AppHost.cs | 2 +- playground/README.md | 2 +- .../api1-roles-mysqlserver.module.bicep | 2 +- .../api2-roles-mysqlserver.module.bicep | 2 +- .../Components/Layout/AppFooter.razor | 4 +- playground/orleans/Orleans.AppHost/Program.cs | 2 +- src/Aspire.AppHost.Sdk/SDK/Sdk.in.targets | 2 +- .../Agents/CommonAgentApplicators.cs | 2 +- src/Aspire.Cli/Commands/AddCommand.cs | 2 +- .../Configuration/AspireConfigFile.cs | 4 +- .../Configuration/ConfigurationService.cs | 2 +- .../Interaction/ConsoleInteractionService.cs | 2 +- .../NuGet/NuGetPackagePrefetcher.cs | 2 +- src/Aspire.Cli/Program.cs | 2 +- src/Aspire.Cli/Projects/LanguageService.cs | 2 +- src/Aspire.Cli/Projects/ProjectLocator.cs | 2 +- src/Aspire.Cli/README.md | 4 +- .../Templating/DotNetTemplateFactory.cs | 2 +- .../Templates/ts-starter/frontend/src/App.tsx | 2 +- src/Aspire.Cli/Utils/CliHostEnvironment.cs | 2 +- src/Aspire.Cli/Utils/ConfigurationHelper.cs | 2 +- .../Model/ResourceViewModel.cs | 2 +- src/Aspire.Dashboard/wwwroot/css/app.css | 2 +- src/Aspire.Hosting.AppHost/README.md | 2 +- .../build/Aspire.Hosting.AppHost.props | 2 +- .../README.md | 2 +- .../ContainerAppContext.cs | 2 +- .../ContainerAppJobContext.cs | 2 +- src/Aspire.Hosting.Azure.AppService/README.md | 2 +- .../README.md | 2 +- .../README.md | 4 +- src/Aspire.Hosting.Azure.CosmosDB/README.md | 4 +- src/Aspire.Hosting.Azure.EventHubs/README.md | 4 +- src/Aspire.Hosting.Azure.Functions/README.md | 2 +- src/Aspire.Hosting.Azure.Kusto/README.md | 2 +- src/Aspire.Hosting.Azure.Network/README.md | 2 +- .../README.md | 2 +- src/Aspire.Hosting.Azure.PostgreSQL/README.md | 4 +- src/Aspire.Hosting.Azure.Redis/README.md | 4 +- src/Aspire.Hosting.Azure.Search/README.md | 4 +- src/Aspire.Hosting.Azure.ServiceBus/README.md | 4 +- src/Aspire.Hosting.Azure.SignalR/README.md | 4 +- .../AzureSqlServerResource.cs | 2 +- src/Aspire.Hosting.Azure.Sql/README.md | 4 +- src/Aspire.Hosting.Azure.Storage/README.md | 4 +- src/Aspire.Hosting.Azure.WebPubSub/README.md | 4 +- src/Aspire.Hosting.Azure/README.md | 2 +- src/Aspire.Hosting.DevTunnels/README.md | 2 +- src/Aspire.Hosting.Docker/README.md | 2 +- src/Aspire.Hosting.Foundry/README.md | 4 +- .../GarnetBuilderExtensions.cs | 2 +- src/Aspire.Hosting.Garnet/README.md | 4 +- src/Aspire.Hosting.GitHub.Models/README.md | 4 +- src/Aspire.Hosting.JavaScript/README.md | 6 +- src/Aspire.Hosting.Kafka/README.md | 2 +- src/Aspire.Hosting.Keycloak/README.md | 2 +- .../Extensions/ResourceExtensions.cs | 2 +- .../KubernetesResource.cs | 2 +- src/Aspire.Hosting.Kubernetes/README.md | 2 +- src/Aspire.Hosting.Maui/README.md | 2 +- .../MilvusContainerImageTags.cs | 2 +- src/Aspire.Hosting.Milvus/README.md | 2 +- src/Aspire.Hosting.MongoDB/README.md | 2 +- src/Aspire.Hosting.MySql/README.md | 2 +- src/Aspire.Hosting.Nats/README.md | 2 +- src/Aspire.Hosting.OpenAI/README.md | 4 +- src/Aspire.Hosting.Oracle/README.md | 2 +- src/Aspire.Hosting.Orleans/README.md | 2 +- src/Aspire.Hosting.PostgreSQL/README.md | 2 +- .../QdrantBuilderExtensions.cs | 2 +- src/Aspire.Hosting.Qdrant/README.md | 2 +- src/Aspire.Hosting.RabbitMQ/README.md | 2 +- src/Aspire.Hosting.Redis/README.md | 2 +- .../RedisBuilderExtensions.cs | 2 +- src/Aspire.Hosting.Seq/README.md | 2 +- src/Aspire.Hosting.SqlServer/README.md | 2 +- src/Aspire.Hosting.Valkey/README.md | 4 +- .../ValkeyBuilderExtensions.cs | 2 +- src/Aspire.Hosting.Yarp/README.md | 2 +- .../CommandsConfigurationExtensions.cs | 2 +- .../Dashboard/proto/dashboard_service.proto | 4 +- src/Aspire.Hosting/Dcp/DcpExecutor.cs | 6 +- .../DistributedApplicationBuilder.cs | 2 +- .../DotnetToolResourceExtensions.cs | 2 +- .../Exec/ExecResourceManager.cs | 2 +- .../Health/ResourceHealthCheckService.cs | 2 +- src/Aspire.Hosting/README.md | 4 +- .../Aspire.ProjectTemplates.csproj | 2 +- .../aspire-py-starter/frontend/src/App.tsx | 2 +- .../aspire-ts-cs-starter/frontend/src/App.tsx | 2 +- .../Aspire.Azure.AI.Inference/README.md | 4 +- .../Aspire.Azure.AI.OpenAI/README.md | 4 +- .../Aspire.Azure.Data.Tables/README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- src/Components/Aspire.Azure.Npgsql/README.md | 4 +- .../Aspire.Azure.Search.Documents/README.md | 4 +- .../Aspire.Azure.Security.KeyVault/README.md | 4 +- .../Aspire.Azure.Storage.Blobs/README.md | 4 +- .../README.md | 4 +- .../Aspire.Azure.Storage.Queues/README.md | 4 +- .../Aspire.Confluent.Kafka/README.md | 4 +- .../Aspire.Keycloak.Authentication/README.md | 4 +- .../Aspire.Microsoft.Azure.Cosmos/README.md | 4 +- .../README.md | 2 +- .../Aspire.Microsoft.Data.SqlClient/README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- src/Components/Aspire.Milvus.Client/README.md | 4 +- .../Aspire.MongoDB.Driver/README.md | 4 +- .../README.md | 4 +- .../Aspire.MySqlConnector/README.md | 4 +- src/Components/Aspire.NATS.Net/README.md | 4 +- .../README.md | 4 +- src/Components/Aspire.Npgsql/README.md | 4 +- src/Components/Aspire.OpenAI/README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- src/Components/Aspire.Qdrant.Client/README.md | 4 +- .../AspireRabbitMQExtensions.cs | 2 +- .../Aspire.RabbitMQ.Client/README.md | 4 +- src/Components/Aspire.Seq/README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- .../Aspire.StackExchange.Redis/README.md | 4 +- src/Components/README.md | 6 +- .../AspireAzureAIOpenAIExtensionsTests.cs | 2 +- .../AspireTablesExtensionsTests.cs | 2 +- .../AspireEventHubsExtensionsTests.cs | 2 +- .../AspireServiceBusExtensionsTests.cs | 2 +- .../AspireAzureSearchExtensionsTests.cs | 2 +- .../AspireKeyVaultExtensionsTests.cs | 2 +- .../AspireBlobStorageExtensionsTests.cs | 2 +- .../AspireDataLakeExtensionsTests.cs | 2 +- .../AspireQueueStorageExtensionsTests.cs | 2 +- .../Aspire.Cli.EndToEnd.Tests/BannerTests.cs | 2 +- .../Helpers/CliE2EAutomatorHelpers.cs | 6 +- .../JsReactTemplateTests.cs | 2 +- .../PlaywrightCliInstallTests.cs | 2 +- tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs | 4 +- .../StopNonInteractiveTests.cs | 2 +- .../WaitCommandTests.cs | 2 +- .../SigstoreNpmProvenanceCheckerTests.cs | 2 +- .../Commands/DeployCommandTests.cs | 2 +- .../Commands/ExtensionInternalCommandTests.cs | 4 +- .../Commands/RunCommandTests.cs | 2 +- .../ConsoleInteractionServiceTests.cs | 4 +- .../Projects/ProjectLocatorTests.cs | 4 +- .../Projects/ProjectUpdaterTests.cs | 2 +- ...ire.Components.Common.TestUtilities.csproj | 2 +- .../ConformanceTests.cs | 14 +- .../OtelMetricsTests.cs | 2 +- .../OtelTracesTests.cs | 2 +- .../CircularBufferTests.cs | 2 +- .../AcaDeploymentErrorOutputTests.cs | 2 +- .../Helpers/DeploymentE2EAutomatorHelpers.cs | 6 +- tests/Aspire.EndToEnd.Tests/README.md | 2 +- .../KustoFunctionalTests.cs | 10 +- .../AzureAppServiceTests.cs | 4 +- .../AzureBicepResourceTests.cs | 2 +- .../AzureContainerAppsTests.cs | 2 +- .../AzureCosmosDBEmulatorFunctionalTests.cs | 12 +- .../AzureDeployerTests.cs | 2 +- .../AzureEnvironmentResourceTests.cs | 2 +- .../AzureServiceBusExtensionsTests.cs | 8 +- ...CreatesBothSubnetAndStorage.verified.bicep | 4 +- ...othExplicitSubnetAndStorage.verified.bicep | 4 +- ...itStorage_AutoCreatesSubnet.verified.bicep | 4 +- ...itSubnet_AutoCreatesStorage.verified.bicep | 4 +- ...torageBeforePrivateEndpoint.verified.bicep | 4 +- ...SubnetBeforePrivateEndpoint.verified.bicep | 4 +- ...eAssignmentTests.SqlSupport.verified.bicep | 4 +- .../DockerComposeTests.cs | 2 +- .../NodeFunctionalTests.cs | 6 +- .../KafkaFunctionalTests.cs | 6 +- .../KubernetesEnvironmentResourceTests.cs | 4 +- .../OpenAIFunctionalTests.cs | 2 +- .../OracleFunctionalTests.cs | 6 +- .../AddPythonAppTests.cs | 2 +- .../NuGetUtils.Tests.cs | 2 +- .../TestingFactoryTests.cs | 2 +- .../Exec/ProjectResourceExecTests.cs | 4 +- .../Cli/CliOrphanDetectorTests.cs | 4 +- .../DistributedApplicationTests.cs | 4 +- .../DistributedApplicationPipelineTests.cs | 4 +- .../SlimTestProgramTests.cs | 6 +- .../TestDistributedApplicationBuilder.cs | 2 +- .../WithHttpCommandTests.cs | 6 +- .../ValkeyFunctionalTests.cs | 6 +- .../YarpFunctionalTests.cs | 2 +- tests/Aspire.Playground.Tests/AppHostTests.cs | 6 +- .../Aspire.Playground.Tests.csproj | 2 +- .../ProjectSpecificTests.cs | 8 +- ...elo.EntityFrameworkCore.MySql.Tests.csproj | 2 +- .../AspireEFMySqlExtensionsTests.cs | 8 +- .../AspireRabbitMQLoggingTests.cs | 2 +- .../AspireRedisExtensionsTests.cs | 2 +- .../Aspire.Templates.Tests.csproj | 2 +- .../BuildAndRunTemplateTests.cs | 2 +- .../PerTestFrameworkTemplatesTests.cs | 2 +- .../RequiresFeatureAttribute.cs | 4 +- .../AutoRerunTransientCiFailuresTests.cs | 40 +-- .../QuarantineTools.Tests/ActiveIssueTests.cs | 44 +-- .../QuarantineScriptTests.cs | 36 +-- .../TemplatesTesting/BuildEnvironment.cs | 2 +- tests/helix/send-to-helix-inner.proj | 4 +- tools/QuarantineTools/README.md | 4 +- tools/ReleaseNotes/data/whats-new-91.md | 18 +- tools/ReleaseNotes/data/whats-new-92.md | 8 +- tools/ReleaseNotes/data/whats-new-93.md | 8 +- tools/ReleaseNotes/data/whats-new-94.md | 16 +- tools/ReleaseNotes/data/whats-new-95.md | 38 +-- tools/ReleaseNotes/docs/api-documentation.md | 2 +- tools/ReleaseNotes/docs/commit-analysis.md | 4 +- tools/scripts/DownloadFailingJobLogs.cs | 2 +- tools/scripts/README.md | 6 +- 290 files changed, 961 insertions(+), 651 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/10_bug_report.yml b/.github/ISSUE_TEMPLATE/10_bug_report.yml index 9658076d262..2f296f69d5c 100644 --- a/.github/ISSUE_TEMPLATE/10_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/10_bug_report.yml @@ -10,11 +10,11 @@ body: Please keep in mind that the GitHub issue tracker is not intended as a general support forum, but for reporting **non-security** bugs and feature requests. If you believe you have an issue that affects the SECURITY of the platform, please do NOT create an issue and instead email your issue details to secure@microsoft.com. Your report may be eligible for our [bug bounty](https://www.microsoft.com/msrc/bounty-dot-net-core) but ONLY if it is reported through email. - For other types of questions, consider using [Discussions](https://github.com/dotnet/aspire/discussions). + For other types of questions, consider using [Discussions](https://github.com/microsoft/aspire/discussions). - type: checkboxes attributes: label: Is there an existing issue for this? - description: Please search to see if an issue already exists for the bug you encountered ([aspire/issues](https://github.com/dotnet/aspire/issues)). More information on our issue management policies is available [here](https://aka.ms/aspnet/issue-policies). + description: Please search to see if an issue already exists for the bug you encountered ([aspire/issues](https://github.com/microsoft/aspire/issues)). More information on our issue management policies is available [here](https://aka.ms/aspnet/issue-policies). options: - label: I have searched the existing issues required: true diff --git a/.github/ISSUE_TEMPLATE/20_feature-request.yml b/.github/ISSUE_TEMPLATE/20_feature-request.yml index 26cbc8bfb51..b6e6bfbb6f0 100644 --- a/.github/ISSUE_TEMPLATE/20_feature-request.yml +++ b/.github/ISSUE_TEMPLATE/20_feature-request.yml @@ -9,7 +9,7 @@ body: - type: checkboxes attributes: label: Is there an existing issue for this? - description: Please search to see if an issue already exists for the feature you are requesting. (https://github.com/dotnet/aspire/issues). + description: Please search to see if an issue already exists for the feature you are requesting. (https://github.com/microsoft/aspire/issues). options: - label: I have searched the existing issues required: true diff --git a/.github/ISSUE_TEMPLATE/40_blocking_clean_ci.yml b/.github/ISSUE_TEMPLATE/40_blocking_clean_ci.yml index 4ad26ee9157..ce1370aa92c 100644 --- a/.github/ISSUE_TEMPLATE/40_blocking_clean_ci.yml +++ b/.github/ISSUE_TEMPLATE/40_blocking_clean_ci.yml @@ -11,7 +11,7 @@ body: - type: checkboxes attributes: label: Is there an existing issue for this? - description: Please search to see if an issue already exists for the failure you encountered ([aspire/issues](https://github.com/dotnet/aspire/issues)). More information on our issue management policies is available [here](https://aka.ms/aspnet/issue-policies). + description: Please search to see if an issue already exists for the failure you encountered ([aspire/issues](https://github.com/microsoft/aspire/issues)). More information on our issue management policies is available [here](https://aka.ms/aspnet/issue-policies). options: - label: I have searched the existing issues required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 8ba7bed03f0..670c809ec80 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: true contact_links: - name: Aspire Discussions - url: https://github.com/dotnet/aspire/discussions + url: https://github.com/microsoft/aspire/discussions about: For other types of questions, consider using Discussions. - name: Issue Management Policies url: https://aka.ms/aspnet/issue-policies diff --git a/.github/instructions/client-readme.instructions.md b/.github/instructions/client-readme.instructions.md index 5d42a80a2cd..7ac5d9f315a 100644 --- a/.github/instructions/client-readme.instructions.md +++ b/.github/instructions/client-readme.instructions.md @@ -212,16 +212,16 @@ builder.Add{Technology}{Client}("{connectionName}"); ## Additional documentation * {Link to official technology documentation} -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire ``` **Guidelines:** - Always include a link to the official technology/SDK documentation -- Always include the link to Aspire Components README: `https://github.com/dotnet/aspire/tree/main/src/Components/README.md` +- Always include the link to Aspire Components README: `https://github.com/microsoft/aspire/tree/main/src/Components/README.md` - Use bulleted list format with `*` prefix - "Feedback & contributing" section should be separate with just the GitHub link @@ -354,11 +354,11 @@ builder.AddNpgsqlDataSource("postgresdb"); ## Additional documentation * https://www.npgsql.org/doc/basic-usage.html -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres*, *PostgreSQL* and the *Slonik Logo* are trademarks or registered trademarks of the *PostgreSQL Community Association of Canada*, and used with their permission._ ``` @@ -405,7 +405,7 @@ Settings classes follow consistent naming: - ❌ Don't omit prerequisites - ❌ Don't forget to show the dependency injection example - ❌ Don't use inconsistent configuration key naming -- ❌ Don't forget the link to `https://github.com/dotnet/aspire/tree/main/src/Components/README.md` +- ❌ Don't forget the link to `https://github.com/microsoft/aspire/tree/main/src/Components/README.md` - ❌ Don't explain health checks, telemetry, or observability in detail (they're automatically enabled) - ❌ Don't forget trademark notices when applicable diff --git a/.github/instructions/hosting-readme.instructions.md b/.github/instructions/hosting-readme.instructions.md index dbaac938a3d..b144cd65676 100644 --- a/.github/instructions/hosting-readme.instructions.md +++ b/.github/instructions/hosting-readme.instructions.md @@ -133,7 +133,7 @@ configured. See [Local Azure Provisioning](https://aspire.dev/integrations/cloud ```markdown ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire ``` **Guidelines:** @@ -195,7 +195,7 @@ https://aspire.dev/integrations/databases/postgresql-extensions/ ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres*, *PostgreSQL* and the *Slonik Logo* are trademarks or registered trademarks of the *PostgreSQL Community Association of Canada*, and used with their permission._ ```` diff --git a/.github/skills/ci-test-failures/SKILL.md b/.github/skills/ci-test-failures/SKILL.md index e5176423a61..ad2213915e1 100644 --- a/.github/skills/ci-test-failures/SKILL.md +++ b/.github/skills/ci-test-failures/SKILL.md @@ -20,15 +20,15 @@ When CI tests fail, use the `DownloadFailingJobLogs.cs` tool to automatically do Get the run ID from the GitHub Actions URL or use the `gh` CLI: ```bash -# From URL: https://github.com/dotnet/aspire/actions/runs/19846215629 +# From URL: https://github.com/microsoft/aspire/actions/runs/19846215629 # ^^^^^^^^^^ # run ID # Or find the latest run on a branch -gh run list --repo dotnet/aspire --branch --limit 1 --json databaseId --jq '.[0].databaseId' +gh run list --repo microsoft/aspire --branch --limit 1 --json databaseId --jq '.[0].databaseId' # Or for a PR -gh pr checks --repo dotnet/aspire +gh pr checks --repo microsoft/aspire ``` ### Step 2: Run the Tool @@ -66,10 +66,10 @@ The tool creates files in your current directory: ```bash # 1. Check failed jobs on a PR -gh pr checks 14105 --repo dotnet/aspire 2>&1 | Where-Object { $_ -match "fail" } +gh pr checks 14105 --repo microsoft/aspire 2>&1 | Where-Object { $_ -match "fail" } # 2. Get the run ID -$runId = gh run list --repo dotnet/aspire --branch davidfowl/my-branch --limit 1 --json databaseId --jq '.[0].databaseId' +$runId = gh run list --repo microsoft/aspire --branch davidfowl/my-branch --limit 1 --json databaseId --jq '.[0].databaseId' # 3. Download failure logs cd tools/scripts @@ -93,7 +93,7 @@ The tool prints a summary for each failed job: === Failed Job 1/1 === Name: Tests / Integrations macos (Hosting.Azure) / Hosting.Azure (macos-latest) ID: 56864254427 -URL: https://github.com/dotnet/aspire/actions/runs/19846215629/job/56864254427 +URL: https://github.com/microsoft/aspire/actions/runs/19846215629/job/56864254427 Downloading job logs... Saved job logs to: failed_job_0_Tests___Integrations_macos__Hosting_Azure____Hosting_Azure__macos-latest_.log @@ -142,7 +142,7 @@ Get-Content "failed_job_*.log" | Select-String -Pattern "timeout|timed out|Timeo Sometimes job logs aren't available (404). Use annotations instead: ```bash -gh api repos/dotnet/aspire/check-runs//annotations +gh api repos/microsoft/aspire/check-runs//annotations ``` This returns structured error information even when full logs aren't downloadable. @@ -155,7 +155,7 @@ This returns structured error information even when full logs aren't downloadabl **Diagnosis:** ```powershell -gh api repos/dotnet/aspire/check-runs//annotations 2>&1 +gh api repos/microsoft/aspire/check-runs//annotations 2>&1 ``` **Common fixes:** @@ -268,7 +268,7 @@ rm -rf tools/scripts/artifact_* - .NET 10 SDK or later - GitHub CLI (`gh`) installed and authenticated -- Access to the dotnet/aspire repository +- Access to the microsoft/aspire repository ## See Also diff --git a/.github/skills/cli-e2e-testing/SKILL.md b/.github/skills/cli-e2e-testing/SKILL.md index 6e45aa8e87b..b4cacde0f02 100644 --- a/.github/skills/cli-e2e-testing/SKILL.md +++ b/.github/skills/cli-e2e-testing/SKILL.md @@ -524,7 +524,7 @@ gh run list --branch $(git branch --show-current) --workflow CI --limit 5 # Get the run ID from the output or use: RUN_ID=$(gh run list --branch $(git branch --show-current) --workflow CI --limit 1 --json databaseId --jq '.[0].databaseId') echo "Run ID: $RUN_ID" -echo "URL: https://github.com/dotnet/aspire/actions/runs/$RUN_ID" +echo "URL: https://github.com/microsoft/aspire/actions/runs/$RUN_ID" ``` ### Step 2: Find CLI E2E Test Artifacts @@ -538,7 +538,7 @@ Artifact names follow the pattern: `logs--ubuntu-latest` gh run view $RUN_ID --json jobs --jq '.jobs[] | select(.name | test("Cli E2E")) | {name, conclusion}' # List available CLI E2E artifacts -gh api --paginate "repos/dotnet/aspire/actions/runs/$RUN_ID/artifacts" \ +gh api --paginate "repos/microsoft/aspire/actions/runs/$RUN_ID/artifacts" \ --jq '.artifacts[].name' | grep -i "smoke" ``` diff --git a/.github/skills/dependency-update/SKILL.md b/.github/skills/dependency-update/SKILL.md index aa883249335..bac9c344550 100644 --- a/.github/skills/dependency-update/SKILL.md +++ b/.github/skills/dependency-update/SKILL.md @@ -3,7 +3,7 @@ name: dependency-update description: Guides dependency version updates by checking nuget.org for latest versions, triggering the dotnet-migrate-package Azure DevOps pipeline, and monitoring runs. Use this when asked to update external NuGet dependencies. --- -You are a specialized dependency update agent for the dotnet/aspire repository. Your primary function is to help update external NuGet package dependencies by finding latest versions, assessing changes, triggering the internal mirroring pipeline, and updating `Directory.Packages.props`. +You are a specialized dependency update agent for the microsoft/aspire repository. Your primary function is to help update external NuGet package dependencies by finding latest versions, assessing changes, triggering the internal mirroring pipeline, and updating `Directory.Packages.props`. ## Background diff --git a/.github/skills/pr-testing/SKILL.md b/.github/skills/pr-testing/SKILL.md index 9221ae15ec2..366da92e12a 100644 --- a/.github/skills/pr-testing/SKILL.md +++ b/.github/skills/pr-testing/SKILL.md @@ -3,12 +3,12 @@ name: pr-testing description: Downloads and tests Aspire CLI from a PR build, verifies version, and runs test scenarios based on PR changes. Use this when asked to test a pull request. --- -You are a specialized PR testing agent for the dotnet/aspire repository. Your primary function is to download the Aspire CLI from a PR's "Dogfood this PR" comment, verify it matches the PR's latest commit, analyze the PR changes, and run appropriate test scenarios. +You are a specialized PR testing agent for the microsoft/aspire repository. Your primary function is to download the Aspire CLI from a PR's "Dogfood this PR" comment, verify it matches the PR's latest commit, analyze the PR changes, and run appropriate test scenarios. ## Understanding User Requests Parse user requests to extract: -1. **PR identifier** - either a PR number (e.g., `12345`) or full URL (e.g., `https://github.com/dotnet/aspire/pull/12345`) +1. **PR identifier** - either a PR number (e.g., `12345`) or full URL (e.g., `https://github.com/microsoft/aspire/pull/12345`) ### Example Requests @@ -16,7 +16,7 @@ Parse user requests to extract: > Test PR 12345 **By URL:** -> Test https://github.com/dotnet/aspire/pull/12345 +> Test https://github.com/microsoft/aspire/pull/12345 **Implicit:** > Test this PR (when working in a branch with an open PR) @@ -29,11 +29,11 @@ Extract the PR number from the user's input: ```powershell # If URL provided, extract PR number -$prUrl = "https://github.com/dotnet/aspire/pull/12345" +$prUrl = "https://github.com/microsoft/aspire/pull/12345" $prNumber = ($prUrl -split '/')[-1] # Verify PR exists and get details -gh pr view $prNumber --repo dotnet/aspire --json number,title,headRefOid,body,files +gh pr view $prNumber --repo microsoft/aspire --json number,title,headRefOid,body,files ``` ### 2. Get the "Dogfood this PR" Download Link @@ -42,7 +42,7 @@ Fetch the PR comments and find the "Dogfood this PR with:" comment that contains ```powershell # Get PR comments to find dogfood instructions -gh pr view $prNumber --repo dotnet/aspire --json comments --jq '.comments[] | select(.body | contains("Dogfood this PR")) | .body' +gh pr view $prNumber --repo microsoft/aspire --json comments --jq '.comments[] | select(.body | contains("Dogfood this PR")) | .body' ``` The comment typically contains instructions like: @@ -78,7 +78,7 @@ Get the PR's head commit SHA and verify the installed CLI matches: ```powershell # Get PR head commit SHA -$prInfo = gh pr view $prNumber --repo dotnet/aspire --json headRefOid | ConvertFrom-Json +$prInfo = gh pr view $prNumber --repo microsoft/aspire --json headRefOid | ConvertFrom-Json $expectedCommit = $prInfo.headRefOid # Get installed CLI version info @@ -96,10 +96,10 @@ Examine the PR diff to understand what was changed: ```powershell # Get changed files -gh pr view $prNumber --repo dotnet/aspire --json files --jq '.files[].path' +gh pr view $prNumber --repo microsoft/aspire --json files --jq '.files[].path' # Get the PR diff -gh pr diff $prNumber --repo dotnet/aspire +gh pr diff $prNumber --repo microsoft/aspire ``` Categorize the changes: diff --git a/.github/skills/test-management/SKILL.md b/.github/skills/test-management/SKILL.md index 2428ee5d4bc..6ee51740700 100644 --- a/.github/skills/test-management/SKILL.md +++ b/.github/skills/test-management/SKILL.md @@ -3,7 +3,7 @@ name: test-management description: Quarantines or disables flaky/problematic tests using the QuarantineTools utility --- -You are a specialized test management agent for the dotnet/aspire repository. Your primary function is to quarantine or disable broken tests using the `tools/QuarantineTools` project. +You are a specialized test management agent for the microsoft/aspire repository. Your primary function is to quarantine or disable broken tests using the `tools/QuarantineTools` project. ## Understanding User Requests @@ -21,18 +21,18 @@ Parse user requests to extract: ### Example Requests **Disable with ActiveIssue:** -> Disable CliOrphanDetectorAfterTheProcessWasRunningForAWhileThenStops with https://github.com/dotnet/aspire/issues/12314 +> Disable CliOrphanDetectorAfterTheProcessWasRunningForAWhileThenStops with https://github.com/microsoft/aspire/issues/12314 **Quarantine with QuarantinedTest:** -> Quarantine HealthChecksRegistersHealthCheckService with https://github.com/dotnet/aspire/issues/11820 +> Quarantine HealthChecksRegistersHealthCheckService with https://github.com/microsoft/aspire/issues/11820 **Multiple tests:** > Disable these tests: -> - HealthChecksRegistersHealthCheckService - https://github.com/dotnet/aspire/issues/11820 -> - TracingRegistersTraceProvider - https://github.com/dotnet/aspire/issues/11820 +> - HealthChecksRegistersHealthCheckService - https://github.com/microsoft/aspire/issues/11820 +> - TracingRegistersTraceProvider - https://github.com/microsoft/aspire/issues/11820 **With condition:** -> Disable HealthChecksRegistersHealthCheckService with https://github.com/dotnet/aspire/issues/11820 only on Azure DevOps +> Disable HealthChecksRegistersHealthCheckService with https://github.com/microsoft/aspire/issues/11820 only on Azure DevOps ## Task Execution Steps @@ -90,11 +90,11 @@ If the user specified conditional requirements (e.g., "only on Azure DevOps"), Q - "on macOS" → `PlatformDetection.IsMacOS` **Steps to add conditions:** -1. QuarantineTools adds: `[ActiveIssue("https://github.com/dotnet/aspire/issues/12314")]` +1. QuarantineTools adds: `[ActiveIssue("https://github.com/microsoft/aspire/issues/12314")]` 2. Locate the file modified by QuarantineTools 3. Edit the attribute to add the conditional parameters: ```csharp -[ActiveIssue("https://github.com/dotnet/aspire/issues/12314", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] +[ActiveIssue("https://github.com/microsoft/aspire/issues/12314", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] ``` **Example for Theory test with condition:** @@ -102,7 +102,7 @@ If the user specified conditional requirements (e.g., "only on Azure DevOps"), Q [Theory] [InlineData(true)] [InlineData(false)] -[ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] +[ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void ParameterizedTest(bool parameter) { // test code @@ -146,7 +146,7 @@ If build fails: - {Quarantined|Disabled}: TestMethod1 - {Quarantined|Disabled}: TestMethod2 -- Issue: https://github.com/dotnet/aspire/issues/XXXXX +- Issue: https://github.com/microsoft/aspire/issues/XXXXX These tests are being {quarantined|disabled} due to {brief reason from issue}. ``` @@ -157,7 +157,7 @@ These tests are being {quarantined|disabled} due to {brief reason from issue}. - {Unquarantined|Re-enabled}: TestMethod1 - {Unquarantined|Re-enabled}: TestMethod2 -- Issue: https://github.com/dotnet/aspire/issues/XXXXX +- Issue: https://github.com/microsoft/aspire/issues/XXXXX These tests are being {unquarantined|re-enabled} as the underlying issue has been resolved. ``` @@ -270,7 +270,7 @@ After completing the task, provide a summary: ### ✅ Successfully {Quarantined|Disabled|Unquarantined|Re-enabled} - **TestMethod1** in `tests/Project.Tests/File.cs` - - Issue: https://github.com/dotnet/aspire/issues/XXXXX + - Issue: https://github.com/microsoft/aspire/issues/XXXXX - Attribute: [{QuarantinedTest|ActiveIssue}] - Verification: Passed ✓ diff --git a/.github/skills/update-container-images/SKILL.md b/.github/skills/update-container-images/SKILL.md index 2db6ef16330..071d4e44deb 100644 --- a/.github/skills/update-container-images/SKILL.md +++ b/.github/skills/update-container-images/SKILL.md @@ -3,7 +3,7 @@ name: update-container-images description: Updates Docker container image tags used by Aspire hosting integrations. Queries registries for newer tags, uses LLM to determine version-compatible updates, and applies changes. Use this when asked to update container image versions. --- -You are a specialized container image update agent for the dotnet/aspire repository. Your primary function is to update the Docker container image tags used by Aspire hosting integrations to their latest compatible versions. +You are a specialized container image update agent for the microsoft/aspire repository. Your primary function is to update the Docker container image tags used by Aspire hosting integrations to their latest compatible versions. ## Background @@ -137,7 +137,7 @@ Exception: Tags like `4.2-management` in RabbitMQ are derived/computed from the Check the source file for comments about known issues. For example, Milvus has: ```csharp -// Note that when trying to update to v2.6.0 we hit https://github.com/dotnet/aspire/issues/11184 +// Note that when trying to update to v2.6.0 we hit https://github.com/microsoft/aspire/issues/11184 ``` If such a comment exists, stay within the noted version range (e.g., v2.5.x for Milvus) unless you can verify the issue is resolved. diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 06975dcd71c..56c94914e07 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -34,17 +34,17 @@ The `apply-test-attributes.yml` workflow allows repository maintainers to quaran #### Quarantine a flaky test (creates new PR) ``` -/quarantine-test MyTestClass.MyTestMethod https://github.com/dotnet/aspire/issues/1234 +/quarantine-test MyTestClass.MyTestMethod https://github.com/microsoft/aspire/issues/1234 ``` #### Quarantine multiple tests ``` -/quarantine-test TestMethod1 TestMethod2 TestMethod3 https://github.com/dotnet/aspire/issues/1234 +/quarantine-test TestMethod1 TestMethod2 TestMethod3 https://github.com/microsoft/aspire/issues/1234 ``` #### Quarantine a test and push to an existing PR ``` -/quarantine-test MyTestMethod https://github.com/dotnet/aspire/issues/1234 --target-pr https://github.com/dotnet/aspire/pull/5678 +/quarantine-test MyTestMethod https://github.com/microsoft/aspire/issues/1234 --target-pr https://github.com/microsoft/aspire/pull/5678 ``` #### Unquarantine a test (creates new PR) @@ -54,12 +54,12 @@ The `apply-test-attributes.yml` workflow allows repository maintainers to quaran #### Unquarantine and push to an existing PR ``` -/unquarantine-test MyTestMethod --target-pr https://github.com/dotnet/aspire/pull/5678 +/unquarantine-test MyTestMethod --target-pr https://github.com/microsoft/aspire/pull/5678 ``` #### Disable a test due to an active issue ``` -/disable-test MyTestMethod https://github.com/dotnet/aspire/issues/1234 +/disable-test MyTestMethod https://github.com/microsoft/aspire/issues/1234 ``` #### Enable a previously disabled test diff --git a/.github/workflows/apply-test-attributes.yml b/.github/workflows/apply-test-attributes.yml index 910b960ea94..13f5802d605 100644 --- a/.github/workflows/apply-test-attributes.yml +++ b/.github/workflows/apply-test-attributes.yml @@ -13,7 +13,7 @@ concurrency: jobs: quarantine_test: if: >- - github.repository == 'dotnet/aspire' && + github.repository == 'microsoft/aspire' && ( startsWith(github.event.comment.body, '/quarantine-test ') || startsWith(github.event.comment.body, '/unquarantine-test ') || @@ -353,6 +353,16 @@ jobs: body: body }); + # Generate the App token only after verifying the commenter has write access, + # to avoid minting a privileged token for unauthorized users. + - name: Generate GitHub App Token + if: success() + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + # Credentials must persist for git push operations later in workflow - name: Checkout repo if: success() @@ -360,6 +370,7 @@ jobs: with: ref: ${{ steps.determine-target.outputs.checkout_ref }} fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} - name: Setup .NET if: success() @@ -431,6 +442,7 @@ jobs: CHECKOUT_REF: ${{ steps.determine-target.outputs.checkout_ref }} IS_NEW_PR: ${{ steps.determine-target.outputs.is_new_pr }} with: + github-token: ${{ steps.app-token.outputs.token }} script: | const { spawnSync } = require('child_process'); const fs = require('fs'); diff --git a/.github/workflows/auto-rerun-transient-ci-failures.yml b/.github/workflows/auto-rerun-transient-ci-failures.yml index 0bea2adba82..96f8a9255e9 100644 --- a/.github/workflows/auto-rerun-transient-ci-failures.yml +++ b/.github/workflows/auto-rerun-transient-ci-failures.yml @@ -30,7 +30,7 @@ jobs: name: Analyze transient CI failures if: >- ${{ - github.repository_owner == 'dotnet' && + github.repository_owner == 'microsoft' && (github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' && diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index ad38e5632c8..5eea0307e0c 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,3 +1,11 @@ +# TEMPORARY WORKAROUND: This workflow is a local copy of dotnet/arcade's backport-base.yml +# reusable workflow, modified to use a GitHub App token for PR creation. The microsoft org +# disables GITHUB_TOKEN from creating PRs, and the arcade reusable workflow doesn't accept +# a custom token. Once https://github.com/dotnet/arcade/issues/16585 is resolved, this +# workflow should be reverted back to calling the arcade reusable workflow. +# +# Original: dotnet/arcade/.github/workflows/backport-base.yml@66269f6a88f6062f2cccf6eb84660a8a6f5cc5ec + name: Backport PR to branch on: issue_comment: @@ -13,19 +21,252 @@ permissions: actions: write jobs: - backport: - if: ${{ contains(github.event.comment.body, '/backport to') || github.event_name == 'schedule' }} - uses: dotnet/arcade/.github/workflows/backport-base.yml@66269f6a88f6062f2cccf6eb84660a8a6f5cc5ec # 2025-01-13 + cleanup: + if: github.event_name == 'schedule' + uses: dotnet/arcade/.github/workflows/scheduled-action-cleanup-base.yml@main with: - pr_description_template: | - Backport of #%source_pr_number% to %target_branch% + repository_owners: 'dotnet,microsoft' + + backport: + if: >- + github.event_name == 'issue_comment' && + contains(format('{0},', 'dotnet,microsoft'), format('{0},', github.repository_owner)) && + github.event.issue.pull_request != '' && + contains(github.event.comment.body, '/backport to') + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + steps: + - name: Extract backport target branch + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: target-branch-extractor + with: + result-encoding: string + script: | + if (context.eventName !== "issue_comment") throw "Error: This action only works on issue_comment events."; + + // extract the target branch name from the trigger phrase containing these characters: a-z, A-Z, digits, forward slash, dot, hyphen, underscore + const regex = /^\/backport to ([a-zA-Z\d\/\.\-\_]+)/; + target_branch = regex.exec(context.payload.comment.body); + if (target_branch == null) throw "Error: No backport branch found in the trigger phrase."; + + return target_branch[1]; + + - name: Verify user has write access + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const comment_user = context.payload.comment.user.login; + const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({ + owner: context.repo.owner, + repo: context.repo.repo, + username: comment_user + }); + + const writePermissions = ['admin', 'write']; + if (!writePermissions.includes(permission.permission)) { + core.setFailed(`@${comment_user} does not have write access to this repo, backporting is not allowed. Required permissions: write or admin.`); + return; + } + console.log(`Verified ${comment_user} has ${permission.permission} access to the repo.`); + + - name: Unlock comments if PR is locked + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + if: github.event.issue.locked == true + with: + script: | + console.log(`Unlocking locked PR #${context.issue.number}.`); + await github.rest.issues.unlock({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + - name: Post backport started comment to pull request + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const target_branch = '${{ steps.target-branch-extractor.outputs.result }}'; + const workflow_run_url = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + const backport_start_body = `Started backporting to \`${target_branch}\` ([link to workflow run](${workflow_run_url}))`; + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: backport_start_body + }); + + # Generate the App token only after verifying the commenter has write access, + # to avoid minting a privileged token for unauthorized users. + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + + - name: Checkout repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Run backport + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + BACKPORT_PR_TITLE_TEMPLATE: '[%target_branch%] %source_pr_title%' + BACKPORT_PR_DESCRIPTION_TEMPLATE: | + Backport of #%source_pr_number% to %target_branch% + + /cc %cc_users% + + ## Customer Impact + + ## Testing + + ## Risk + + ## Regression? + with: + github-token: ${{ steps.app-token.outputs.token }} + script: | + const target_branch = '${{ steps.target-branch-extractor.outputs.result }}'; + const repo_owner = context.payload.repository.owner.login; + const repo_name = context.payload.repository.name; + const pr_number = context.payload.issue.number; + const comment_user = context.payload.comment.user.login; + const workflow_run_url = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + + const wrap_in_code_block = (language, content) => `\`\`\`${language}\n${content}\n\`\`\``; + const wrap_in_details_block = (summary, content) => `
\n${summary}\n\n${content}\n
`; + + // Post a comment on the PR and return the comment URL + async function postComment(body) { + const { data: comment } = await github.rest.issues.createComment({ + owner: repo_owner, + repo: repo_name, + issue_number: pr_number, + body + }); + return comment.html_url; + } + + try { + // Permission check already done in the "Verify user has write access" step above. + + try { await exec.exec(`git ls-remote --exit-code --heads origin ${target_branch}`) } catch { throw new Error(`Error: The specified backport target branch "${target_branch}" wasn't found in the repo.`); } + console.log(`Backport target branch: ${target_branch}`); + + console.log("Applying backport patch"); + + await exec.exec(`git checkout ${target_branch}`); + await exec.exec(`git clean -xdff`); + + // configure git + await exec.exec(`git config user.name "github-actions"`); + await exec.exec(`git config user.email "github-actions@github.com"`); + + // create temporary backport branch + const temp_branch = `backport/pr-${pr_number}-to-${target_branch}`; + await exec.exec(`git checkout -b ${temp_branch}`); + + // skip opening PR if the branch already exists on the origin remote since that means it was opened + // by an earlier backport and force pushing to the branch updates the existing PR + let should_open_pull_request = true; + try { + await exec.exec(`git ls-remote --exit-code --heads origin ${temp_branch}`); + should_open_pull_request = false; + } catch { } + + // download and apply patch + const patch_file = 'changes.patch'; + await exec.exec(`bash -c "gh pr diff --patch ${pr_number} > ${patch_file}"`); + + const base_switches = '--3way --empty=keep --ignore-whitespace --keep-non-patch'; + const git_am_command = `git am ${base_switches} ${patch_file}`; + let git_am_output = `$ ${git_am_command}\n\n`; + let git_am_failed = false; + try { + await exec.exec(git_am_command, [], { + listeners: { + stdout: function stdout(data) { git_am_output += data; }, + stderr: function stderr(data) { git_am_output += data; } + } + }); + } catch (error) { + git_am_output += error; + git_am_failed = true; + } + + if (git_am_failed) { + const details = `${wrap_in_code_block('console', git_am_output)}\n[Link to workflow output](${workflow_run_url})`; + const git_am_failed_body = `@${comment_user} backporting to \`${target_branch}\` failed, the patch most likely resulted in conflicts. Please backport manually!\n${wrap_in_details_block('git am output', details)}`; + postComment(git_am_failed_body); + core.setFailed("git am failed, most likely due to a merge conflict."); + return; + } + + // push the temp branch to the repository + await exec.exec(`git push --force --set-upstream origin HEAD:${temp_branch}`); + + if (!should_open_pull_request) { + console.log("Backport temp branch already exists, skipping opening a PR."); + return; + } + + // prepare the GitHub PR details + + // get users to cc (append PR author if different from user who issued the backport command) + let cc_users = `@${comment_user}`; + if (comment_user != context.payload.issue.user.login) cc_users += ` @${context.payload.issue.user.login}`; + + // replace the special placeholder tokens with values + const { BACKPORT_PR_TITLE_TEMPLATE, BACKPORT_PR_DESCRIPTION_TEMPLATE } = process.env - /cc %cc_users% + const backport_pr_title = BACKPORT_PR_TITLE_TEMPLATE + .replace(/%target_branch%/g, target_branch) + .replace(/%source_pr_title%/g, context.payload.issue.title) + .replace(/%source_pr_number%/g, context.payload.issue.number) + .replace(/%source_pr_author%/g, context.payload.issue.user.login) + .replace(/%cc_users%/g, cc_users); - ## Customer Impact + const backport_pr_description = BACKPORT_PR_DESCRIPTION_TEMPLATE + .replace(/%target_branch%/g, target_branch) + .replace(/%source_pr_title%/g, context.payload.issue.title) + .replace(/%source_pr_number%/g, context.payload.issue.number) + .replace(/%source_pr_author%/g, context.payload.issue.user.login) + .replace(/%cc_users%/g, cc_users); - ## Testing + // open the GitHub PR + const { data: backportPullRequest } = await github.rest.pulls.create({ + owner: repo_owner, + repo: repo_name, + title: backport_pr_title, + body: backport_pr_description, + head: temp_branch, + base: target_branch + }); - ## Risk + console.log(`Successfully opened backport PR #${backportPullRequest.number}: ${backportPullRequest.html_url}`); + } catch (error) { + const body = `@${comment_user} an error occurred while backporting to \`${target_branch}\`. See the [workflow output](${workflow_run_url}) for details.`; + const comment_url = await postComment(body); + console.log(`Posted comment: ${comment_url}`); + core.setFailed(error); + } - ## Regression? + - name: Re-lock PR comments + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + if: github.event.issue.locked == true && (success() || failure()) + with: + script: | + console.log(`Locking previously locked PR #${context.issue.number} again.`); + await github.rest.issues.lock({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + lock_reason: "resolved" + }); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43d27085e63..c1a478269d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: prepare_for_ci: runs-on: ubuntu-latest name: Prepare for CI - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} outputs: skip_workflow: ${{ (steps.check_for_changes.outputs.no_changes == 'true' || steps.check_for_changes.outputs.only_changed == 'true') && 'true' || 'false' }} @@ -42,11 +42,11 @@ jobs: uses: ./.github/workflows/tests.yml name: Tests needs: [prepare_for_ci] - if: ${{ github.repository_owner == 'dotnet' && needs.prepare_for_ci.outputs.skip_workflow != 'true' }} + if: ${{ github.repository_owner == 'microsoft' && needs.prepare_for_ci.outputs.skip_workflow != 'true' }} # This job is used for branch protection. It fails if any of the dependent jobs failed results: - if: ${{ always() && github.repository_owner == 'dotnet' }} + if: ${{ always() && github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest name: Final Results needs: [prepare_for_ci, tests] diff --git a/.github/workflows/cli-e2e-recording-comment.yml b/.github/workflows/cli-e2e-recording-comment.yml index 12cc617d929..59bdf709f44 100644 --- a/.github/workflows/cli-e2e-recording-comment.yml +++ b/.github/workflows/cli-e2e-recording-comment.yml @@ -20,7 +20,7 @@ jobs: # Only run on the dotnet org and for pull requests # Note: This runs for all conclusions (success, failure, cancelled) since recordings may exist if: >- - ${{ github.repository_owner == 'dotnet' && + ${{ github.repository_owner == 'microsoft' && (github.event.workflow_run.event == 'pull_request' || github.event_name == 'workflow_dispatch') }} runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/deployment-cleanup.yml b/.github/workflows/deployment-cleanup.yml index 08dc4f72429..da39cf2c036 100644 --- a/.github/workflows/deployment-cleanup.yml +++ b/.github/workflows/deployment-cleanup.yml @@ -39,7 +39,7 @@ jobs: cleanup: name: Cleanup Azure Resources runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} environment: deployment-testing steps: diff --git a/.github/workflows/deployment-test-command.yml b/.github/workflows/deployment-test-command.yml index 3f5f13be858..0a7203e455d 100644 --- a/.github/workflows/deployment-test-command.yml +++ b/.github/workflows/deployment-test-command.yml @@ -23,7 +23,7 @@ jobs: ${{ github.event.comment.body == '/deployment-test' && github.event.issue.pull_request && - github.repository_owner == 'dotnet' + github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest diff --git a/.github/workflows/deployment-tests.yml b/.github/workflows/deployment-tests.yml index ed8fd442cfb..0e51d0c4abd 100644 --- a/.github/workflows/deployment-tests.yml +++ b/.github/workflows/deployment-tests.yml @@ -35,7 +35,7 @@ jobs: notify-start: name: Notify PR runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' && inputs.pr_number != '' }} + if: ${{ github.repository_owner == 'microsoft' && inputs.pr_number != '' }} permissions: pull-requests: write steps: @@ -57,7 +57,7 @@ jobs: enumerate: name: Enumerate Tests runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} permissions: contents: read outputs: @@ -79,7 +79,7 @@ jobs: build: name: Build runs-on: 8-core-ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} permissions: contents: read steps: @@ -307,7 +307,7 @@ jobs: ### Labels This issue was automatically created by the deployment E2E test workflow. - /cc @dotnet/aspire-team + /cc @microsoft/aspire-team `; // Check if a similar issue already exists (created today) diff --git a/.github/workflows/dogfood-comment.yml b/.github/workflows/dogfood-comment.yml index 8ab61df202d..4ba8cd806cf 100644 --- a/.github/workflows/dogfood-comment.yml +++ b/.github/workflows/dogfood-comment.yml @@ -19,7 +19,7 @@ on: jobs: add-dogfood-comment: # Only run on the dotnet org to avoid running on forks - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest permissions: pull-requests: write @@ -30,8 +30,8 @@ jobs: script: | // Get PR number from either the PR event or manual input const prNumber = context.payload.number || context.payload.inputs.pr_number; - const bashScript = 'https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh'; - const psScript = 'https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1'; + const bashScript = 'https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh'; + const psScript = 'https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1'; // Unique marker to identify dogfooding comments const dogfoodMarker = ''; diff --git a/.github/workflows/generate-api-diffs.yml b/.github/workflows/generate-api-diffs.yml index ee9b8ed098d..9d07b5ecb12 100644 --- a/.github/workflows/generate-api-diffs.yml +++ b/.github/workflows/generate-api-diffs.yml @@ -12,7 +12,7 @@ permissions: jobs: generate-and-pr: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -26,10 +26,17 @@ jobs: done continue-on-error: true + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Create or update pull request uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.app-token.outputs.token }} branch: update-api-diffs base: main labels: | diff --git a/.github/workflows/generate-ats-diffs.yml b/.github/workflows/generate-ats-diffs.yml index e0ff941f34f..ba41b7eace0 100644 --- a/.github/workflows/generate-ats-diffs.yml +++ b/.github/workflows/generate-ats-diffs.yml @@ -12,7 +12,7 @@ permissions: jobs: generate-and-pr: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -76,10 +76,17 @@ jobs: exit 1 fi + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Create or update pull request uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.app-token.outputs.token }} branch: update-ats-diffs base: main labels: | diff --git a/.github/workflows/labeler-cache-retention.yml b/.github/workflows/labeler-cache-retention.yml index 94985ee0bde..f56ef22b7a9 100644 --- a/.github/workflows/labeler-cache-retention.yml +++ b/.github/workflows/labeler-cache-retention.yml @@ -21,7 +21,7 @@ env: jobs: restore-cache: # Do not automatically run the workflow on forks outside the 'dotnet' org - if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }} + if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/labeler-predict-issues.yml b/.github/workflows/labeler-predict-issues.yml index e2447a37c7b..1efebdd4e55 100644 --- a/.github/workflows/labeler-predict-issues.yml +++ b/.github/workflows/labeler-predict-issues.yml @@ -29,7 +29,7 @@ env: jobs: predict-issue-label: # Do not automatically run the workflow on forks outside the 'dotnet' org - if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }} + if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest permissions: issues: write diff --git a/.github/workflows/labeler-predict-pulls.yml b/.github/workflows/labeler-predict-pulls.yml index b7a735bf6f1..74b3f679ec2 100644 --- a/.github/workflows/labeler-predict-pulls.yml +++ b/.github/workflows/labeler-predict-pulls.yml @@ -43,7 +43,7 @@ env: jobs: predict-pull-label: # Do not automatically run the workflow on forks outside the 'dotnet' org - if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'dotnet' }} + if: ${{ github.event_name == 'workflow_dispatch' || github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest permissions: pull-requests: write diff --git a/.github/workflows/locker.yml b/.github/workflows/locker.yml index 2b045e526f9..fdc01ddbd2f 100644 --- a/.github/workflows/locker.yml +++ b/.github/workflows/locker.yml @@ -20,7 +20,7 @@ permissions: jobs: main: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - name: Checkout Actions uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/.github/workflows/markdownlint.yml b/.github/workflows/markdownlint.yml index 0a2587516a9..baa26b83b15 100644 --- a/.github/workflows/markdownlint.yml +++ b/.github/workflows/markdownlint.yml @@ -12,7 +12,7 @@ jobs: lint: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/.github/workflows/pr-docs-hook.yml b/.github/workflows/pr-docs-hook.yml index 7ae9bb8baaf..d13e21bf4f8 100644 --- a/.github/workflows/pr-docs-hook.yml +++ b/.github/workflows/pr-docs-hook.yml @@ -20,7 +20,7 @@ permissions: jobs: check-docs-needed: # Only run on the dotnet org to avoid running on forks - if: (github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch') && github.repository_owner == 'dotnet' + if: (github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch') && github.repository_owner == 'microsoft' runs-on: ubuntu-latest steps: @@ -157,7 +157,7 @@ jobs: run: | ISSUE_BODY="## Documentation Update Required - This issue was automatically created based on changes from dotnet/aspire PR #${{ steps.pr.outputs.number }}. + This issue was automatically created based on changes from microsoft/aspire PR #${{ steps.pr.outputs.number }}. **PR Title:** ${{ steps.pr_details.outputs.title }} **PR Author:** @${{ steps.pr_details.outputs.author }} @@ -170,7 +170,7 @@ jobs: ISSUE_URL=$(gh issue create \ --repo microsoft/aspire.dev \ - --title "Docs update for dotnet/aspire#${{ steps.pr.outputs.number }}: ${{ steps.pr_details.outputs.title }}" \ + --title "Docs update for microsoft/aspire#${{ steps.pr.outputs.number }}: ${{ steps.pr_details.outputs.title }}" \ --body "$ISSUE_BODY" \ --label "docs-from-code") diff --git a/.github/workflows/pr-review-needed.yml b/.github/workflows/pr-review-needed.yml index 0fdbbee80f7..7da2bffaeae 100644 --- a/.github/workflows/pr-review-needed.yml +++ b/.github/workflows/pr-review-needed.yml @@ -24,7 +24,7 @@ permissions: jobs: get-prs-needing-review: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} outputs: prs: ${{ steps.get-prs.outputs.prs }} steps: diff --git a/.github/workflows/refresh-manifests.yml b/.github/workflows/refresh-manifests.yml index d37ae9c25c1..621f5b389d3 100644 --- a/.github/workflows/refresh-manifests.yml +++ b/.github/workflows/refresh-manifests.yml @@ -12,7 +12,7 @@ permissions: jobs: generate-and-pr: runs-on: windows-latest # Using Windows because the script uses PowerShell and build.cmd - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -26,10 +26,17 @@ jobs: run: | ./eng/refreshManifests.ps1 + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Create or update pull request uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.app-token.outputs.token }} branch: update-manifests base: main commit-message: "[Automated] Update Playground Manifests" diff --git a/.github/workflows/refresh-typescript-sdks.yml b/.github/workflows/refresh-typescript-sdks.yml index deadec5638d..a465371d17b 100644 --- a/.github/workflows/refresh-typescript-sdks.yml +++ b/.github/workflows/refresh-typescript-sdks.yml @@ -12,7 +12,7 @@ permissions: jobs: generate-and-pr: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/.github/workflows/release-github-tasks.yml b/.github/workflows/release-github-tasks.yml index 798cf083d88..7c84cae0033 100644 --- a/.github/workflows/release-github-tasks.yml +++ b/.github/workflows/release-github-tasks.yml @@ -238,8 +238,8 @@ jobs: ## What's New in Aspire $VERSION See the full changelog and documentation at: - - 📖 [Documentation](https://learn.microsoft.com/dotnet/aspire/) - - 🐛 [Known Issues](https://github.com/dotnet/aspire/issues?q=is%3Aissue+is%3Aopen+label%3A%22known-issue%22) + - 📖 [Documentation](https://learn.microsoft.com/microsoft/aspire/) + - 🐛 [Known Issues](https://github.com/microsoft/aspire/issues?q=is%3Aissue+is%3Aopen+label%3A%22known-issue%22) ### Installation @@ -306,6 +306,13 @@ jobs: inputs.skip_merge_pr != true runs-on: ubuntu-latest steps: + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Checkout Repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 with: @@ -314,7 +321,7 @@ jobs: - name: Check for Existing PR id: check-pr env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app-token.outputs.token }} run: | RELEASE_BRANCH="${{ inputs.release_branch }}" EXISTING_PR=$(gh pr list --head "$RELEASE_BRANCH" --base main --json number --jq '.[0].number // empty') @@ -351,7 +358,7 @@ jobs: if: steps.check-pr.outputs.pr_exists != 'true' && inputs.dry_run != true uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 # v1 with: - token: ${{ github.token }} + token: ${{ steps.app-token.outputs.token }} title: "Merge ${{ inputs.release_branch }} to main after v${{ inputs.release_version }} release" body: | This PR merges the `${{ inputs.release_branch }}` branch back to `main` after the v${{ inputs.release_version }} release. @@ -363,7 +370,7 @@ jobs: --- *Created automatically by the release workflow.* - head: ${{ inputs.release_branch }} + branch: ${{ inputs.release_branch }} base: main labels: | area-infrastructure @@ -380,16 +387,24 @@ jobs: inputs.is_prerelease != true runs-on: ubuntu-latest steps: + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Checkout Repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 with: ref: main fetch-depth: 1 + token: ${{ steps.app-token.outputs.token }} - name: Check for Existing PR id: check-pr env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app-token.outputs.token }} run: | BRANCH_NAME="update-baseline-${{ inputs.release_version }}" EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number // empty') @@ -463,7 +478,7 @@ jobs: if: steps.check-pr.outputs.pr_exists != 'true' && inputs.dry_run != true uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 # v1 with: - token: ${{ github.token }} + token: ${{ steps.app-token.outputs.token }} title: "Update PackageValidationBaselineVersion to ${{ inputs.release_version }}" body: | This PR updates the `PackageValidationBaselineVersion` to `${{ inputs.release_version }}` after the release. @@ -475,7 +490,7 @@ jobs: --- *Created automatically by the release workflow.* - head: update-baseline-${{ inputs.release_version }} + branch: update-baseline-${{ inputs.release_version }} base: main labels: | area-infrastructure diff --git a/.github/workflows/specialized-test-runner.yml b/.github/workflows/specialized-test-runner.yml index d390a68d534..0e01c55c8bb 100644 --- a/.github/workflows/specialized-test-runner.yml +++ b/.github/workflows/specialized-test-runner.yml @@ -34,7 +34,7 @@ jobs: generate_tests_matrix: name: Generate test runsheet runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} outputs: runsheet: ${{ steps.generate_tests_matrix.outputs.runsheet }} requiresNugets: ${{ steps.check_nugets.outputs.requiresNugets }} @@ -109,13 +109,13 @@ jobs: build_packages: name: Build packages needs: [generate_tests_matrix] - if: ${{ github.repository_owner == 'dotnet' && needs.generate_tests_matrix.outputs.requiresNugets == 'true' }} + if: ${{ github.repository_owner == 'microsoft' && needs.generate_tests_matrix.outputs.requiresNugets == 'true' }} uses: ./.github/workflows/build-packages.yml build_cli_archives: name: Build native CLI archives needs: [generate_tests_matrix] - if: ${{ github.repository_owner == 'dotnet' && (needs.generate_tests_matrix.outputs.requiresNugets == 'true' || needs.generate_tests_matrix.outputs.requiresCliArchive == 'true') }} + if: ${{ github.repository_owner == 'microsoft' && (needs.generate_tests_matrix.outputs.requiresNugets == 'true' || needs.generate_tests_matrix.outputs.requiresCliArchive == 'true') }} uses: ./.github/workflows/build-cli-native-archives.yml run_tests: @@ -125,7 +125,7 @@ jobs: fail-fast: false matrix: tests: ${{ fromJson(needs.generate_tests_matrix.outputs.runsheet) }} - if: ${{ github.repository_owner == 'dotnet' && !cancelled() && !failure() }} + if: ${{ github.repository_owner == 'microsoft' && !cancelled() && !failure() }} uses: ./.github/workflows/run-tests.yml with: testShortName: ${{ matrix.tests.project }} @@ -138,7 +138,7 @@ jobs: requiresCliArchive: ${{ matrix.tests.requiresCliArchive == true }} results: - if: ${{ always() && github.repository_owner == 'dotnet' }} + if: ${{ always() && github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest name: Final Results needs: [generate_tests_matrix, build_packages, build_cli_archives, run_tests] diff --git a/.github/workflows/tests-outerloop.yml b/.github/workflows/tests-outerloop.yml index a78aa745eb5..7c432d205d8 100644 --- a/.github/workflows/tests-outerloop.yml +++ b/.github/workflows/tests-outerloop.yml @@ -16,7 +16,7 @@ on: schedule: - cron: '0 2 * * *' # Daily at 02:00 UTC - # TEMPORARILY DISABLED pull_request trigger due to #12143 (disk space issues): https://github.com/dotnet/aspire/issues/12143 + # TEMPORARILY DISABLED pull_request trigger due to #12143 (disk space issues): https://github.com/microsoft/aspire/issues/12143 # pull_request: # paths: # - '.github/actions/**' diff --git a/.github/workflows/tests-quarantine.yml b/.github/workflows/tests-quarantine.yml index 5be9a65b99c..0561e1462ef 100644 --- a/.github/workflows/tests-quarantine.yml +++ b/.github/workflows/tests-quarantine.yml @@ -17,7 +17,7 @@ on: # Run every 2 hours. Quarantined tests are run frequently to catch flaky tests with a low failure rate. - cron: '0 */2 * * *' - # TEMPORARILY DISABLED pull_request trigger due to #12143 (disk space issues): https://github.com/dotnet/aspire/issues/12143 + # TEMPORARILY DISABLED pull_request trigger due to #12143 (disk space issues): https://github.com/microsoft/aspire/issues/12143 # pull_request: # paths: # - '.github/actions/**' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fa971d627a5..b2295116337 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -219,7 +219,7 @@ jobs: uses: ./.github/workflows/typescript-sdk-tests.yml results: - if: ${{ always() && github.repository_owner == 'dotnet' }} + if: ${{ always() && github.repository_owner == 'microsoft' }} runs-on: ubuntu-latest name: Final Test Results needs: [ diff --git a/.github/workflows/update-ai-foundry-models.yml b/.github/workflows/update-ai-foundry-models.yml index 4a2adfcf3f3..12b245a171a 100644 --- a/.github/workflows/update-ai-foundry-models.yml +++ b/.github/workflows/update-ai-foundry-models.yml @@ -12,7 +12,7 @@ permissions: jobs: generate-and-pr: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -23,10 +23,17 @@ jobs: "$GITHUB_WORKSPACE/dotnet.sh" run GenModel.cs "$GITHUB_WORKSPACE/dotnet.sh" run GenModel.cs --local + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Create or update pull request uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.app-token.outputs.token }} branch: update-ai-foundry-models base: main commit-message: "[Automated] Update Microsoft Foundry Models" diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 581e6b75d55..d19b4931d1b 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -13,7 +13,7 @@ permissions: jobs: update-dependencies: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -39,11 +39,18 @@ jobs: rm nuget.config git checkout -- . + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Create Pull Request id: create-pr uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.app-token.outputs.token }} branch: update-dependencies commit-message: "[Automated] Updating package dependencies" title: "[Automated] Update dependencies" diff --git a/.github/workflows/update-github-models.yml b/.github/workflows/update-github-models.yml index 01a6ede3f6d..43aafc9b013 100644 --- a/.github/workflows/update-github-models.yml +++ b/.github/workflows/update-github-models.yml @@ -12,7 +12,7 @@ permissions: jobs: generate-and-pr: runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dotnet' }} + if: ${{ github.repository_owner == 'microsoft' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -24,10 +24,17 @@ jobs: set -e "$GITHUB_WORKSPACE/dotnet.sh" run GenModel.cs + - name: Generate GitHub App Token + id: app-token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + with: + app-id: ${{ secrets.ASPIRE_BOT_APP_ID }} + private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }} + - name: Create or update pull request uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.app-token.outputs.token }} branch: update-github-models base: main commit-message: "[Automated] Update Github Models" diff --git a/AGENTS.md b/AGENTS.md index a3fe3f7e3d6..17d8a85a47c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -253,19 +253,19 @@ Use these commands in any issue or PR comment. They require write access to the ```bash # Quarantine a flaky test (creates a new PR) -/quarantine-test Namespace.Type.Method https://github.com/dotnet/aspire/issues/1234 +/quarantine-test Namespace.Type.Method https://github.com/microsoft/aspire/issues/1234 # Quarantine multiple tests at once -/quarantine-test TestMethod1 TestMethod2 https://github.com/dotnet/aspire/issues/1234 +/quarantine-test TestMethod1 TestMethod2 https://github.com/microsoft/aspire/issues/1234 # Quarantine and push to an existing PR -/quarantine-test TestMethod https://github.com/dotnet/aspire/issues/1234 --target-pr https://github.com/dotnet/aspire/pull/5678 +/quarantine-test TestMethod https://github.com/microsoft/aspire/issues/1234 --target-pr https://github.com/microsoft/aspire/pull/5678 # Unquarantine a test (creates a new PR) /unquarantine-test Namespace.Type.Method # Unquarantine and push to an existing PR -/unquarantine-test TestMethod --target-pr https://github.com/dotnet/aspire/pull/5678 +/unquarantine-test TestMethod --target-pr https://github.com/microsoft/aspire/pull/5678 ``` When you comment on a PR, the changes are automatically pushed to that PR's branch (no need for `--target-pr`). @@ -276,7 +276,7 @@ For local development, use the QuarantineTools directly: ```bash # Quarantine a test -dotnet run --project tools/QuarantineTools -- -q -i https://github.com/dotnet/aspire/issues/1234 Full.Namespace.Type.Method +dotnet run --project tools/QuarantineTools -- -q -i https://github.com/microsoft/aspire/issues/1234 Full.Namespace.Type.Method # Unquarantine a test dotnet run --project tools/QuarantineTools -- -u Full.Namespace.Type.Method @@ -288,29 +288,29 @@ dotnet run --project tools/QuarantineTools -- -u Full.Namespace.Type.Method - These tests are completely skipped until the underlying issue is resolved. - Use this for tests that are **blocked**, not for flaky tests (use `QuarantinedTest` for flaky tests). -Example: `[ActiveIssue("https://github.com/dotnet/aspire/issues/1234")]` +Example: `[ActiveIssue("https://github.com/microsoft/aspire/issues/1234")]` ### Disable/Enable via GitHub Commands (Preferred) ```bash # Disable a test due to an active issue (creates a new PR) -/disable-test Namespace.Type.Method https://github.com/dotnet/aspire/issues/1234 +/disable-test Namespace.Type.Method https://github.com/microsoft/aspire/issues/1234 # Disable and push to an existing PR -/disable-test TestMethod https://github.com/dotnet/aspire/issues/1234 --target-pr https://github.com/dotnet/aspire/pull/5678 +/disable-test TestMethod https://github.com/microsoft/aspire/issues/1234 --target-pr https://github.com/microsoft/aspire/pull/5678 # Enable a previously disabled test (creates a new PR) /enable-test Namespace.Type.Method # Enable and push to an existing PR -/enable-test TestMethod --target-pr https://github.com/dotnet/aspire/pull/5678 +/enable-test TestMethod --target-pr https://github.com/microsoft/aspire/pull/5678 ``` ### Disable/Enable via Local Tool ```bash # Disable a test with ActiveIssue -dotnet run --project tools/QuarantineTools -- -q -m activeissue -i https://github.com/dotnet/aspire/issues/1234 Full.Namespace.Type.Method +dotnet run --project tools/QuarantineTools -- -q -m activeissue -i https://github.com/microsoft/aspire/issues/1234 Full.Namespace.Type.Method # Enable a test (remove ActiveIssue) dotnet run --project tools/QuarantineTools -- -u -m activeissue Full.Namespace.Type.Method diff --git a/Directory.Build.props b/Directory.Build.props index e6d941e1378..e06b96f9811 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,10 +11,10 @@ $([MSBuild]::NormalizeDirectory($(TestsSharedDir), 'RepoTesting')) $(MSBuildThisFileDirectory)/src/Vendoring/ - + $(PackageIconFullPath) $(SharedDir)Aspire_icon_256.png - https://github.com/dotnet/aspire + https://github.com/microsoft/aspire false true true @@ -34,9 +34,9 @@ $([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'DashboardArtifacts', '$(Configuration)')) $(ArtifactsShippingPackagesDir) - + - + diff --git a/README.md b/README.md index dd0e881309b..2481eb49eb9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Aspire -[![Tests](https://github.com/dotnet/aspire/actions/workflows/tests.yml/badge.svg?branch=main&event=push)](https://github.com/dotnet/aspire/actions/workflows/tests.yml) +[![Tests](https://github.com/microsoft/aspire/actions/workflows/tests.yml/badge.svg?branch=main&event=push)](https://github.com/microsoft/aspire/actions/workflows/tests.yml) [![Build Status](https://dev.azure.com/dnceng-public/public/_apis/build/status%2Fdotnet%2Faspire%2Fdotnet.aspire?branchName=main)](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=274&branchName=main) -[![Help Wanted](https://img.shields.io/github/issues/dotnet/aspire/help%20wanted?style=flat&color=%24EC820&label=help%20wanted)](https://github.com/dotnet/aspire/labels/help%20wanted) -[![Good First Issue](https://img.shields.io/github/issues/dotnet/aspire/good%20first%20issue?style=flat&color=%24EC820&label=good%20first%20issue)](https://github.com/dotnet/aspire/labels/good%20first%20issue) +[![Help Wanted](https://img.shields.io/github/issues/microsoft/aspire/help%20wanted?style=flat&color=%24EC820&label=help%20wanted)](https://github.com/microsoft/aspire/labels/help%20wanted) +[![Good First Issue](https://img.shields.io/github/issues/microsoft/aspire/good%20first%20issue?style=flat&color=%24EC820&label=good%20first%20issue)](https://github.com/microsoft/aspire/labels/good%20first%20issue) [![Discord](https://img.shields.io/discord/1361488941836140614?style=flat&logo=discord&logoColor=white&label=Join%20our%20Discord&labelColor=512bd4&color=cyan)](https://discord.gg/raNPcaaSj8) ## What is Aspire? @@ -15,7 +15,7 @@ Aspire gives you a unified toolchain: launch and debug your entire app locally w ## Useful links - [Aspire overview and documentation](https://aspire.dev/docs/) -- [Aspire samples repository](https://github.com/dotnet/aspire-samples) +- [Aspire samples repository](https://github.com/microsoft/aspire-samples) - [Dogfooding pull requests](docs/dogfooding-pull-requests.md) - Test changes from specific pull requests locally ## Getting started diff --git a/docs/area-owners.md b/docs/area-owners.md index ef4d2fe0edb..e47a1ff69eb 100644 --- a/docs/area-owners.md +++ b/docs/area-owners.md @@ -6,21 +6,21 @@ If you need to tag folks on an issue or PR, you will generally want to tag the o | Area | Lead | Owners | Notes | | --------------------------------------------------------------------------------------------------------------------------- | ----------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| [area-acquisition](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-acquisition) | @joperezr | @aspire/area-acquisition | Issues/PRs related to how Aspire is installed and acquired | -| [area-app-model](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-app-model) | @adityamandaleeka | @aspire/area-app-model | Issues/PRs related to the Aspire app model and Aspire AppHost | -| [area-app-testing](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-app-testing) | @ReubenBond | @aspire/area-app-testing | Issues/PRs related to the framework we provide for scenario testing of Aspire apps | -| [area-integrations](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-integrations) | @sebastienros | @aspire/area-integrations | Issues/PRs related to Aspire Integrations | -| [area-dashboard](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-dashboard) | @JakeRadMSFT | @aspire/area-dashboard | Issues/PRs related to the Dashboard UI | -| [area-deployment](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-deployment) | @davidfowl | @aspire/area-deployment | Issues/PRs related to deploying Aspire apps | -| [area-docs](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-docs) | @IEvangelist | @aspire/area-docs | Issues/PRs related to documentation | -| [area-engineering-systems](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-engineering-systems) | @joperezr | @aspire/area-engineering-systems | Issues/PRs related to how the repository is built and tested (build and test infrastructure) | -| [area-meta](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-meta) | @danmoseley | @aspire/area-meta | Issues/PRs that don't really match any of the other areas | -| [area-orchestrator](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-orchestrator) | @dbreshears | @aspire/area-orchestrator | Issues/PRs related to DCP (Devex Control Plane) | -| [area-samples](https://github.com/dotnet/aspire-samples/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-samples) | @DamianEdwards | @aspire/area-samples | Issues/PRs related to the Aspire samples. These are in the [dotnet/aspire-samples](https://github.com/dotnet/aspire-samples) repo. | -| [area-service-discovery](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-service-discovery) | @ReubenBond | @aspire/area-service-discovery | Issues/PRs related to Aspire's Service Discovery and communication between services | -| [area-templates](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-templates) | @DamianEdwards | @aspire/area-templates | Issues/PRs related to the Aspire templates | -| [area-telemetry](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-telemetry) | @maddymontaquila | @aspire/area-telemetry | Issues/PRs related to telemetry (logs, metrics, tracing) | -| [area-tooling](https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-tooling) | @JakeRadMSFT | @aspire/area-tooling | Issues/PRs related to Visual Studio and Visual Studio Code tooling for Aspire | +| [area-acquisition](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-acquisition) | @joperezr | @aspire/area-acquisition | Issues/PRs related to how Aspire is installed and acquired | +| [area-app-model](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-app-model) | @adityamandaleeka | @aspire/area-app-model | Issues/PRs related to the Aspire app model and Aspire AppHost | +| [area-app-testing](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-app-testing) | @ReubenBond | @aspire/area-app-testing | Issues/PRs related to the framework we provide for scenario testing of Aspire apps | +| [area-integrations](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-integrations) | @sebastienros | @aspire/area-integrations | Issues/PRs related to Aspire Integrations | +| [area-dashboard](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-dashboard) | @JakeRadMSFT | @aspire/area-dashboard | Issues/PRs related to the Dashboard UI | +| [area-deployment](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-deployment) | @davidfowl | @aspire/area-deployment | Issues/PRs related to deploying Aspire apps | +| [area-docs](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-docs) | @IEvangelist | @aspire/area-docs | Issues/PRs related to documentation | +| [area-engineering-systems](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-engineering-systems) | @joperezr | @aspire/area-engineering-systems | Issues/PRs related to how the repository is built and tested (build and test infrastructure) | +| [area-meta](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-meta) | @danmoseley | @aspire/area-meta | Issues/PRs that don't really match any of the other areas | +| [area-orchestrator](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-orchestrator) | @dbreshears | @aspire/area-orchestrator | Issues/PRs related to DCP (Devex Control Plane) | +| [area-samples](https://github.com/microsoft/aspire-samples/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-samples) | @DamianEdwards | @aspire/area-samples | Issues/PRs related to the Aspire samples. These are in the [microsoft/aspire-samples](https://github.com/microsoft/aspire-samples) repo. | +| [area-service-discovery](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-service-discovery) | @ReubenBond | @aspire/area-service-discovery | Issues/PRs related to Aspire's Service Discovery and communication between services | +| [area-templates](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-templates) | @DamianEdwards | @aspire/area-templates | Issues/PRs related to the Aspire templates | +| [area-telemetry](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-telemetry) | @maddymontaquila | @aspire/area-telemetry | Issues/PRs related to telemetry (logs, metrics, tracing) | +| [area-tooling](https://github.com/microsoft/aspire/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-tooling) | @JakeRadMSFT | @aspire/area-tooling | Issues/PRs related to Visual Studio and Visual Studio Code tooling for Aspire | ## Community Triagers diff --git a/docs/dogfooding-pull-requests.md b/docs/dogfooding-pull-requests.md index 9758ec1bbbb..8ef28152def 100644 --- a/docs/dogfooding-pull-requests.md +++ b/docs/dogfooding-pull-requests.md @@ -23,7 +23,7 @@ They download the correct build artifacts for your OS/architecture, install the Notes: - On Alpine and other musl-based distros, use `--os linux-musl` (Bash) or `-OS linux-musl` (PowerShell). -- You can target a fork by setting `ASPIRE_REPO=owner/repo` in your environment. Defaults to `dotnet/aspire`. +- You can target a fork by setting `ASPIRE_REPO=owner/repo` in your environment. Defaults to `microsoft/aspire`. ## What gets installed @@ -47,14 +47,14 @@ Pick one of the approaches below. - Run remotely (downloads and executes the script from main): ```bash - curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 1234 + curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 1234 ``` ### One-liner (PowerShell) - Run remotely in PowerShell: ```powershell - iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 1234" + iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 1234" ``` ### From a local clone (Bash) @@ -116,7 +116,7 @@ The scripts auto-detect your OS and architecture and locate the latest `ci.yml` - Bash: `-v/--verbose`, `-k/--keep-archive`, `--dry-run` - PowerShell: `-Verbose`, `-WhatIf` (PowerShell's dry-run), or provide equivalent parameters if present -- Target a fork instead of `dotnet/aspire`: +- Target a fork instead of `microsoft/aspire`: - Bash: ```bash ASPIRE_REPO=myfork/aspire ./eng/scripts/get-aspire-cli-pr.sh 1234 diff --git a/docs/machine-requirements.md b/docs/machine-requirements.md index 3a42c3fde2c..7126f936657 100644 --- a/docs/machine-requirements.md +++ b/docs/machine-requirements.md @@ -63,4 +63,4 @@ With that, you can build and run the Aspire repo on Alpine Linux. > :warning: Aspire currently only directly supports the x64/amd64 architecture for Alpine/musl. If you want to build or run Aspire in Alpine on arm64, you may need to use an arm64/x64 compatibility layer like `qemu`. > -> :warning: Alpine Linux support was added in [this commit](https://github.com/dotnet/aspire/commit/cc2706a90848deec90aa166054e1b2a4ecf94689) and isn't supported in earlier releases. Additionally, Alpine Linux is not currently part of our CI test suite. \ No newline at end of file +> :warning: Alpine Linux support was added in [this commit](https://github.com/microsoft/aspire/commit/cc2706a90848deec90aa166054e1b2a4ecf94689) and isn't supported in earlier releases. Additionally, Alpine Linux is not currently part of our CI test suite. \ No newline at end of file diff --git a/docs/quarantined-tests.md b/docs/quarantined-tests.md index 7baf6cd55fb..f9c87dbb554 100644 --- a/docs/quarantined-tests.md +++ b/docs/quarantined-tests.md @@ -47,7 +47,7 @@ dotnet exec YourTestAssembly.dll --filter-trait "quarantined=true" ```csharp [Fact] -[QuarantinedTest("https://github.com/dotnet/aspire/issues/7920")] +[QuarantinedTest("https://github.com/microsoft/aspire/issues/7920")] public async Task FlakyTest() { // Test implementation diff --git a/docs/release-process.md b/docs/release-process.md index 853ba501daa..2d3bb07e5bd 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -1,6 +1,6 @@ # Aspire Release Process -This document describes the release process for dotnet/aspire, including both the automated workflows and manual steps required by the release manager. +This document describes the release process for microsoft/aspire, including both the automated workflows and manual steps required by the release manager. ## Overview @@ -82,7 +82,7 @@ After automation completes: - Baseline version PR: Updates `PackageValidationBaselineVersion` 2. **Verify the release**: - - Check the [GitHub Releases page](https://github.com/dotnet/aspire/releases) + - Check the [GitHub Releases page](https://github.com/microsoft/aspire/releases) - Verify packages on [NuGet.org](https://www.nuget.org/packages?q=owner%3Adotnet+aspire) - Test installation: `dotnet new install Aspire.ProjectTemplates::VERSION` @@ -136,10 +136,10 @@ The pipeline uses the `Aspire-Release-Secrets` variable group. Note that NuGet p | Connection Name | Purpose | |-----------------|---------| -| `NuGet.org - dotnet/aspire` | NuGet service connection for publishing packages to NuGet.org | +| `NuGet.org - microsoft/aspire` | NuGet service connection for publishing packages to NuGet.org | | `Darc: Maestro Production` | Used for darc channel promotion | -> **Note**: The `NuGet.org - dotnet/aspire` service connection must be configured in Azure DevOps Project Settings → Service connections with: +> **Note**: The `NuGet.org - microsoft/aspire` service connection must be configured in Azure DevOps Project Settings → Service connections with: > - **Type**: NuGet > - **Authentication**: ApiKey > - **Feed URL**: `https://api.nuget.org/v3/index.json` @@ -175,7 +175,7 @@ This indicates a mismatch between the expected release commit and an existing ta The `1ES.PublishNuget@1` task is configured with `allowPackageConflicts: true`, which means it will skip packages that already exist on NuGet.org. If publishing fails: 1. Check the pipeline logs for specific error messages -2. Verify the service connection `NuGet.org - dotnet/aspire` is properly configured +2. Verify the service connection `NuGet.org - microsoft/aspire` is properly configured 3. Ensure the API key in the service connection has push permissions for the package IDs 4. Re-run the pipeline (it will skip already-published packages) diff --git a/docs/specs/appmodel.md b/docs/specs/appmodel.md index 3a6f3b2bea4..d7a754fb5cc 100644 --- a/docs/specs/appmodel.md +++ b/docs/specs/appmodel.md @@ -370,7 +370,7 @@ builder.WaitFor(otherResource) This resource can wait on other resources. A ParameterResource is an example of resources that cannot wait. -> **Source:** These APIs and behaviors are defined in the [Aspire.Hosting](https://github.com/dotnet/aspire/blob/main/src/Aspire.Hosting/api/Aspire.Hosting.cs) package. +> **Source:** These APIs and behaviors are defined in the [Aspire.Hosting](https://github.com/microsoft/aspire/blob/main/src/Aspire.Hosting/api/Aspire.Hosting.cs) package. --- diff --git a/docs/specs/bundle.md b/docs/specs/bundle.md index 63f8618500d..ae15bb6b504 100644 --- a/docs/specs/bundle.md +++ b/docs/specs/bundle.md @@ -798,7 +798,7 @@ The self-extracting binary is the **recommended distribution format** — one fi ### Download Locations -- **GitHub Releases**: `https://github.com/dotnet/aspire/releases` +- **GitHub Releases**: `https://github.com/microsoft/aspire/releases` - **aspire.dev**: Direct download links on documentation site --- diff --git a/docs/specs/dashboard-http-api.md b/docs/specs/dashboard-http-api.md index e1daf534b38..ec53f2445a6 100644 --- a/docs/specs/dashboard-http-api.md +++ b/docs/specs/dashboard-http-api.md @@ -8,8 +8,8 @@ The Dashboard exposes telemetry data via a REST HTTP API that provides data in * **Related:** -- Issue: -- PR: +- Issue: +- PR: - MCP implementation: `src/Aspire.Dashboard/Mcp/AspireTelemetryMcpTools.cs` ## Design Philosophy diff --git a/docs/specs/polyglot-apphost-testing.md b/docs/specs/polyglot-apphost-testing.md index a402ee2ae82..3e3cc6c576a 100644 --- a/docs/specs/polyglot-apphost-testing.md +++ b/docs/specs/polyglot-apphost-testing.md @@ -217,7 +217,7 @@ Retrieves resource console logs from the `ResourceLoggerService`. These are the > **Note:** These are console logs (stdout/stderr), not OpenTelemetry structured logs. For OTel logs, traces, and metrics, use the Dashboard's telemetry views or configure an external collector. -See [GitHub Issue #8069](https://github.com/dotnet/aspire/issues/8069) for the original feature request. +See [GitHub Issue #8069](https://github.com/microsoft/aspire/issues/8069) for the original feature request. ```bash aspire logs [resource] [--project ] [--follow] [--format json] diff --git a/docs/specs/polyglot-apphost.md b/docs/specs/polyglot-apphost.md index f71adf29186..24b080d72d0 100644 --- a/docs/specs/polyglot-apphost.md +++ b/docs/specs/polyglot-apphost.md @@ -1451,7 +1451,7 @@ This section explains how to develop and test custom language SDKs using a local 1. Clone the Aspire repository: ```bash - git clone https://github.com/dotnet/aspire.git + git clone https://github.com/microsoft/aspire.git cd aspire ``` diff --git a/eng/Signing.props b/eng/Signing.props index 7c99bdcd71e..4de73bac6a3 100644 --- a/eng/Signing.props +++ b/eng/Signing.props @@ -16,7 +16,7 @@ - +
diff --git a/eng/pipelines/README.md b/eng/pipelines/README.md index af492149ac7..2cdb0911344 100644 --- a/eng/pipelines/README.md +++ b/eng/pipelines/README.md @@ -1,6 +1,6 @@ # Azure DevOps Pipelines -This directory contains Azure DevOps pipeline definitions for the dotnet/aspire repository. +This directory contains Azure DevOps pipeline definitions for the microsoft/aspire repository. ## Pipeline Files diff --git a/eng/pipelines/release-publish-nuget.yml b/eng/pipelines/release-publish-nuget.yml index f75a62e246f..ebc243fbf85 100644 --- a/eng/pipelines/release-publish-nuget.yml +++ b/eng/pipelines/release-publish-nuget.yml @@ -1,6 +1,6 @@ # Release Pipeline: Publish NuGet Packages and Promote to GA Channel # -# This pipeline automates the release process for dotnet/aspire: +# This pipeline automates the release process for microsoft/aspire: # 1. Downloads signed packages from a specified build # 2. Publishes packages to NuGet.org # 3. Promotes the build to the Aspire GA channel via darc @@ -47,7 +47,7 @@ variables: - template: /eng/pipelines/common-variables.yml@self - template: /eng/common/templates-official/variables/pool-providers.yml@self # Variable group containing secrets (VscePublishToken for future use) - # Note: NuGet publishing uses service connection 'NuGet.org - dotnet/aspire' instead of API key + # Note: NuGet publishing uses service connection 'NuGet.org - microsoft/aspire' instead of API key - group: Aspire-Release-Secrets # Variable group containing aspire-winget-bot-pat and aspire-homebrew-bot-pat for WinGet and Homebrew publishing - group: Aspire-Secrets @@ -385,7 +385,7 @@ extends: packagesToPush: '$(Pipeline.Workspace)/packages/PackageArtifacts/*.nupkg' packageParentPath: '$(Pipeline.Workspace)/packages/PackageArtifacts' nuGetFeedType: external - publishFeedCredentials: 'NuGet.org - dotnet/aspire' + publishFeedCredentials: 'NuGet.org - microsoft/aspire' # Skip message when SkipNuGetPublish is true - ${{ if eq(parameters.SkipNuGetPublish, true) }}: diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index 7abce19a784..5f3bf630398 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -275,7 +275,7 @@ steps: "${{ parameters.buildScript }} -testnobuild -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog /maxcpucount:1 /p:BuildInParallel=false $(_OfficialBuildIdArgs)" env: DOCKER_BUILDKIT: 1 - # https://github.com/dotnet/aspire/issues/5195#issuecomment-2271687822 + # https://github.com/microsoft/aspire/issues/5195#issuecomment-2271687822 DOTNET_ASPIRE_DEPENDENCY_CHECK_TIMEOUT: 180 ASPIRE__TEST__DCPLOGBASEPATH: $(Build.ArtifactStagingDirectory)/artifacts/log/dcp DOTNET_ROOT: $(Build.SourcesDirectory)/.dotnet diff --git a/eng/scripts/README.md b/eng/scripts/README.md index 2478b74d761..4bd34d73312 100644 --- a/eng/scripts/README.md +++ b/eng/scripts/README.md @@ -171,19 +171,19 @@ Additional scripts exist to fetch CLI and NuGet artifacts from a pull request bu Quick fetch (Bash): ```bash -curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- +curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- ``` Quick fetch (PowerShell): ```powershell -iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } " +iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } " ``` NuGet hive path pattern: `~/.aspire/hives/pr-/packages` ### Repository Override -You can point the PR artifact retrieval scripts at a fork by setting the `ASPIRE_REPO` environment variable to `owner/name` before invoking the script (defaults to `dotnet/aspire`). +You can point the PR artifact retrieval scripts at a fork by setting the `ASPIRE_REPO` environment variable to `owner/name` before invoking the script (defaults to `microsoft/aspire`). Examples: diff --git a/eng/scripts/get-aspire-cli-pr.ps1 b/eng/scripts/get-aspire-cli-pr.ps1 index 95b645e5ed1..fdd662016dd 100755 --- a/eng/scripts/get-aspire-cli-pr.ps1 +++ b/eng/scripts/get-aspire-cli-pr.ps1 @@ -71,7 +71,7 @@ .EXAMPLE Piped execution - iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } + iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } .NOTES Requires GitHub CLI (gh) to be installed and authenticated @@ -79,7 +79,7 @@ VS Code extension installation requires VS Code CLI (code) to be available in PATH .PARAMETER ASPIRE_REPO (environment variable) - Override repository (owner/name). Default: dotnet/aspire + Override repository (owner/name). Default: microsoft/aspire Example: $env:ASPIRE_REPO = 'myfork/aspire' #> @@ -128,7 +128,7 @@ $Script:AspireCliArtifactNamePrefix = "aspire-cli" $Script:ExtensionArtifactName = "aspire-extension" $Script:IsModernPowerShell = $PSVersionTable.PSVersion.Major -ge 6 -and $PSVersionTable.PSEdition -eq "Core" $Script:HostOS = "unset" -$Script:Repository = if ($env:ASPIRE_REPO -and $env:ASPIRE_REPO.Trim()) { $env:ASPIRE_REPO.Trim() } else { 'dotnet/aspire' } +$Script:Repository = if ($env:ASPIRE_REPO -and $env:ASPIRE_REPO.Trim()) { $env:ASPIRE_REPO.Trim() } else { 'microsoft/aspire' } $Script:GHReposBase = "repos/$($Script:Repository)" # True if the script is executed from a file (pwsh -File … or .\get-aspire-cli-pr.ps1) @@ -299,11 +299,11 @@ function Get-MachineArchitecture { { @("x86_64", "amd64") -contains $_ } { return "x64" } { @("aarch64", "arm64") -contains $_ } { return "arm64" } default { - throw "Architecture '$unameArch' not supported. If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + throw "Architecture '$unameArch' not supported. If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" } } } else { - throw "Architecture '$runtimeArch' not supported (uname unavailable). If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + throw "Architecture '$runtimeArch' not supported (uname unavailable). If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" } } } @@ -313,7 +313,7 @@ function Get-MachineArchitecture { } } - throw "Architecture detection failed (no supported detection path). If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + throw "Architecture detection failed (no supported detection path). If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" } catch { throw "Architecture detection failed: $($_.Exception.Message)" @@ -343,7 +343,7 @@ function Get-CLIArchitectureFromArchitecture { return "arm64" } default { - throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" } } } @@ -908,7 +908,7 @@ function Find-WorkflowRun { $runId = Invoke-GitHubAPICall -Endpoint "$Script:GHReposBase/actions/workflows/ci.yml/runs?event=pull_request&head_sha=$HeadSHA" -JqFilter ".workflow_runs | sort_by(.created_at, .updated_at) | reverse | .[0].id" -ErrorMessage "Failed to query workflow runs for SHA: $HeadSHA" if ([string]::IsNullOrWhiteSpace($runId) -or $runId -eq "null") { - throw "No ci.yml workflow run found for PR SHA: $HeadSHA. This could mean no workflow has been triggered for this SHA $HeadSHA . Check at https://github.com/dotnet/aspire/actions/workflows/ci.yml" + throw "No ci.yml workflow run found for PR SHA: $HeadSHA. This could mean no workflow has been triggered for this SHA $HeadSHA . Check at https://github.com/microsoft/aspire/actions/workflows/ci.yml" } Write-Message "Found workflow run ID: $runId" -Level Verbose @@ -938,7 +938,7 @@ function Invoke-ArtifactDownload { if ($LASTEXITCODE -ne 0) { Write-Message "gh run download command failed with exit code $LASTEXITCODE . Command: $($downloadCommand -join ' ')" -Level Verbose - throw "Failed to download artifact '$ArtifactName' from run: $RunId . If the workflow is still running then the artifact named '$ArtifactName' may not be available yet. Check at https://github.com/dotnet/aspire/actions/runs/$RunId#artifacts" + throw "Failed to download artifact '$ArtifactName' from run: $RunId . If the workflow is still running then the artifact named '$ArtifactName' may not be available yet. Check at https://github.com/microsoft/aspire/actions/runs/$RunId#artifacts" } } } diff --git a/eng/scripts/get-aspire-cli-pr.sh b/eng/scripts/get-aspire-cli-pr.sh index f39c5a689ce..3500a6ddcd4 100755 --- a/eng/scripts/get-aspire-cli-pr.sh +++ b/eng/scripts/get-aspire-cli-pr.sh @@ -12,8 +12,8 @@ readonly CLI_ARCHIVE_ARTIFACT_NAME_PREFIX="cli-native-archives" readonly ASPIRE_CLI_ARTIFACT_NAME_PREFIX="aspire-cli" readonly EXTENSION_ARTIFACT_NAME="aspire-extension" -# Repository: Allow override via ASPIRE_REPO env var (owner/name). Default: dotnet/aspire -readonly REPO="${ASPIRE_REPO:-dotnet/aspire}" +# Repository: Allow override via ASPIRE_REPO env var (owner/name). Default: microsoft/aspire +readonly REPO="${ASPIRE_REPO:-microsoft/aspire}" readonly GH_REPOS_BASE="repos/${REPO}" # Global constants @@ -85,7 +85,7 @@ EXAMPLES: ./get-aspire-cli-pr.sh 1234 --skip-path ./get-aspire-cli-pr.sh 1234 --dry-run - curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- + curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- REQUIREMENTS: - GitHub CLI (gh) must be installed and authenticated @@ -93,7 +93,7 @@ REQUIREMENTS: - VS Code extension installation requires VS Code CLI (code) to be available in PATH ENVIRONMENT VARIABLES: - ASPIRE_REPO Override repository (owner/name). Default: dotnet/aspire + ASPIRE_REPO Override repository (owner/name). Default: microsoft/aspire Example: export ASPIRE_REPO=myfork/aspire EOF @@ -283,7 +283,7 @@ get_cli_architecture_from_architecture() { printf "arm64" ;; *) - say_error "Architecture $architecture not supported. If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + say_error "Architecture $architecture not supported. If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" return 1 ;; esac @@ -301,7 +301,7 @@ detect_architecture() { printf "arm64" ;; *) - say_error "Architecture $uname_m not supported. If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + say_error "Architecture $uname_m not supported. If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" return 1 ;; esac @@ -582,7 +582,7 @@ check_gh_dependency() { # Function to make GitHub API calls with proper error handling # Parameters: -# $1 - endpoint: The GitHub API endpoint (e.g., "repos/dotnet/aspire/pulls/123") +# $1 - endpoint: The GitHub API endpoint (e.g., "repos/microsoft/aspire/pulls/123") # $2 - jq_filter: Optional jq filter to apply to the response (e.g., ".head.sha") # $3 - error_message: Optional custom error message prefix # Returns: diff --git a/eng/scripts/get-aspire-cli.ps1 b/eng/scripts/get-aspire-cli.ps1 index a8061e2f5d2..ba19348a774 100755 --- a/eng/scripts/get-aspire-cli.ps1 +++ b/eng/scripts/get-aspire-cli.ps1 @@ -341,7 +341,7 @@ function Get-CLIArchitectureFromArchitecture { return "arm64" } default { - throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" } } } diff --git a/eng/scripts/get-aspire-cli.sh b/eng/scripts/get-aspire-cli.sh index 9791f0cbcdd..b5d882bd879 100755 --- a/eng/scripts/get-aspire-cli.sh +++ b/eng/scripts/get-aspire-cli.sh @@ -230,7 +230,7 @@ get_cli_architecture_from_architecture() { printf "arm64" ;; *) - say_error "Architecture $architecture not supported. If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + say_error "Architecture $architecture not supported. If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" return 1 ;; esac @@ -248,7 +248,7 @@ detect_architecture() { printf "arm64" ;; *) - say_error "Architecture $uname_m not supported. If you think this is a bug, report it at https://github.com/dotnet/aspire/issues" + say_error "Architecture $uname_m not supported. If you think this is a bug, report it at https://github.com/microsoft/aspire/issues" return 1 ;; esac diff --git a/eng/scripts/get-cli-e2e-recording.ps1 b/eng/scripts/get-cli-e2e-recording.ps1 index d6af3766c3f..c059f7caec9 100644 --- a/eng/scripts/get-cli-e2e-recording.ps1 +++ b/eng/scripts/get-cli-e2e-recording.ps1 @@ -55,7 +55,7 @@ param( ) $ErrorActionPreference = "Stop" -$Repo = "dotnet/aspire" +$Repo = "microsoft/aspire" # Check for gh CLI if (-not (Get-Command gh -ErrorAction SilentlyContinue)) { diff --git a/eng/scripts/get-cli-e2e-recording.sh b/eng/scripts/get-cli-e2e-recording.sh index 9ff53beb7cc..ed6c16c873d 100755 --- a/eng/scripts/get-cli-e2e-recording.sh +++ b/eng/scripts/get-cli-e2e-recording.sh @@ -29,7 +29,7 @@ OUTPUT_DIR="/tmp/cli-e2e-recordings" PLAY_RECORDING=false LIST_ONLY=false BRANCH="" -REPO="dotnet/aspire" +REPO="microsoft/aspire" # Show help show_help() { diff --git a/eng/winget/microsoft.aspire.prerelease/Aspire.locale.en-US.yaml.template b/eng/winget/microsoft.aspire.prerelease/Aspire.locale.en-US.yaml.template index c000e010071..3655c7d5ed2 100644 --- a/eng/winget/microsoft.aspire.prerelease/Aspire.locale.en-US.yaml.template +++ b/eng/winget/microsoft.aspire.prerelease/Aspire.locale.en-US.yaml.template @@ -5,12 +5,12 @@ PackageVersion: "${VERSION}" PackageLocale: en-US Publisher: Microsoft Corporation PublisherUrl: https://aspire.dev/ -PublisherSupportUrl: https://github.com/dotnet/aspire/issues +PublisherSupportUrl: https://github.com/microsoft/aspire/issues PrivacyUrl: https://privacy.microsoft.com/privacystatement PackageName: Aspire CLI (Prerelease) PackageUrl: https://aspire.dev/ License: MIT -LicenseUrl: https://github.com/dotnet/aspire/blob/main/LICENSE.TXT +LicenseUrl: https://github.com/microsoft/aspire/blob/main/LICENSE.TXT Copyright: (c) Microsoft ${YEAR} ShortDescription: Prerelease CLI tool for building observable, production-ready distributed applications with Aspire Description: > diff --git a/eng/winget/microsoft.aspire/Aspire.locale.en-US.yaml.template b/eng/winget/microsoft.aspire/Aspire.locale.en-US.yaml.template index e020b5ccccc..ad4ae1c06e9 100644 --- a/eng/winget/microsoft.aspire/Aspire.locale.en-US.yaml.template +++ b/eng/winget/microsoft.aspire/Aspire.locale.en-US.yaml.template @@ -5,13 +5,13 @@ PackageVersion: "${VERSION}" PackageLocale: en-US Publisher: Microsoft Corporation PublisherUrl: https://aspire.dev/ -PublisherSupportUrl: https://github.com/dotnet/aspire/issues +PublisherSupportUrl: https://github.com/microsoft/aspire/issues PrivacyUrl: https://privacy.microsoft.com/privacystatement Moniker: aspire PackageName: Aspire CLI PackageUrl: https://aspire.dev/ License: MIT -LicenseUrl: https://github.com/dotnet/aspire/blob/main/LICENSE.TXT +LicenseUrl: https://github.com/microsoft/aspire/blob/main/LICENSE.TXT Copyright: (c) Microsoft ${YEAR} ShortDescription: CLI tool for building observable, production-ready distributed applications with Aspire Description: > diff --git a/extension/README.md b/extension/README.md index cf6ec5065d8..53a0acb6db6 100644 --- a/extension/README.md +++ b/extension/README.md @@ -135,7 +135,7 @@ Right-click a resource to start, stop, or restart it, view its logs, run resourc The dashboard gives you a live view of your running app — all your resources and their health, endpoint URLs, console logs from every service, structured logs (via OpenTelemetry), distributed traces across services, and metrics. -![Aspire Dashboard showing running resources](https://raw.githubusercontent.com/dotnet/aspire/main/extension/resources/aspire-dashboard-dark.png) +![Aspire Dashboard showing running resources](https://raw.githubusercontent.com/microsoft/aspire/main/extension/resources/aspire-dashboard-dark.png) It opens automatically when you start your app. You can pick which browser it uses with the `aspire.dashboardBrowser` setting — system default browser, or Chrome, Edge, or Firefox as a debug session. When using a debug browser, the `aspire.closeDashboardOnDebugEnd` setting controls whether it closes automatically when you stop debugging. Firefox also requires the [Firefox Debugger](https://marketplace.visualstudio.com/items?itemName=firefox-devtools.vscode-firefox-debug) extension. @@ -209,10 +209,10 @@ Turn it on by setting `aspire.registerMcpServerInWorkspace` to `true`. When enab ## Feedback and Issues -Found a bug or have an idea? File it on the [dotnet/aspire](https://github.com/dotnet/aspire/issues) repo: +Found a bug or have an idea? File it on the [microsoft/aspire](https://github.com/microsoft/aspire/issues) repo: -- [Report a bug](https://github.com/dotnet/aspire/issues/new?template=10_bug_report.yml&labels=area-extension) -- [Request a feature](https://github.com/dotnet/aspire/issues/new?template=20_feature-request.yml&labels=area-extension) +- [Report a bug](https://github.com/microsoft/aspire/issues/new?template=10_bug_report.yml&labels=area-extension) +- [Request a feature](https://github.com/microsoft/aspire/issues/new?template=20_feature-request.yml&labels=area-extension) ### Learn more diff --git a/extension/package.json b/extension/package.json index 76efa790608..c2d96ef3343 100644 --- a/extension/package.json +++ b/extension/package.json @@ -8,7 +8,7 @@ "icon": "dotnet-aspire-logo-128.png", "license": "SEE LICENSE IN LICENSE.TXT", "bugs": { - "url": "https://github.com/dotnet/aspire/issues" + "url": "https://github.com/microsoft/aspire/issues" }, "engines": { "vscode": "^1.98.0" @@ -746,7 +746,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/dotnet/aspire", + "url": "https://github.com/microsoft/aspire", "branch": "main" }, "scripts": { diff --git a/playground/AzureVirtualNetworkEndToEnd/AzureVirtualNetworkEndToEnd.AppHost/api-roles-sql.module.bicep b/playground/AzureVirtualNetworkEndToEnd/AzureVirtualNetworkEndToEnd.AppHost/api-roles-sql.module.bicep index a2e224b59f6..9d947023f3a 100644 --- a/playground/AzureVirtualNetworkEndToEnd/AzureVirtualNetworkEndToEnd.AppHost/api-roles-sql.module.bicep +++ b/playground/AzureVirtualNetworkEndToEnd/AzureVirtualNetworkEndToEnd.AppHost/api-roles-sql.module.bicep @@ -83,7 +83,7 @@ resource script_sql_sqldb 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\n\$maxRetries = 5\r\n\$retryDelay = 60\r\n\$attempt = 0\r\n\$success = \$false\r\n\r\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\r\n \$attempt++\r\n Write-Host "Attempt \$attempt of \$maxRetries..."\r\n try {\r\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\r\n \$success = \$true\r\n Write-Host "SQL command succeeded on attempt \$attempt."\r\n } catch {\r\n Write-Host "Attempt \$attempt failed: \$_"\r\n if (\$attempt -lt \$maxRetries) {\r\n Write-Host "Retrying in \$retryDelay seconds..."\r\n Start-Sleep -Seconds \$retryDelay\r\n } else {\r\n throw\r\n }\r\n }\r\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\n\$maxRetries = 5\r\n\$retryDelay = 60\r\n\$attempt = 0\r\n\$success = \$false\r\n\r\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\r\n \$attempt++\r\n Write-Host "Attempt \$attempt of \$maxRetries..."\r\n try {\r\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\r\n \$success = \$true\r\n Write-Host "SQL command succeeded on attempt \$attempt."\r\n } catch {\r\n Write-Host "Attempt \$attempt failed: \$_"\r\n if (\$attempt -lt \$maxRetries) {\r\n Write-Host "Retrying in \$retryDelay seconds..."\r\n Start-Sleep -Seconds \$retryDelay\r\n } else {\r\n throw\r\n }\r\n }\r\n}' storageAccountSettings: { storageAccountName: sql_store_outputs_name } diff --git a/playground/FoundryAgentEnterprise/frontend/src/App.tsx b/playground/FoundryAgentEnterprise/frontend/src/App.tsx index fb1a47b6150..66f1678f694 100644 --- a/playground/FoundryAgentEnterprise/frontend/src/App.tsx +++ b/playground/FoundryAgentEnterprise/frontend/src/App.tsx @@ -166,7 +166,7 @@ function App() { Learn more about Aspire (opens in new tab) - © @DateTime.Today.Year @@ -14,7 +14,7 @@ @Message - diff --git a/playground/orleans/Orleans.AppHost/Program.cs b/playground/orleans/Orleans.AppHost/Program.cs index a71789225e2..3cf4fb3adc5 100644 --- a/playground/orleans/Orleans.AppHost/Program.cs +++ b/playground/orleans/Orleans.AppHost/Program.cs @@ -8,7 +8,7 @@ .WithClustering(clusteringTable) .WithGrainStorage("Default", grainStorage); -// For local development (see https://github.com/dotnet/aspire/issues/1823 for how to detect), +// For local development (see https://github.com/microsoft/aspire/issues/1823 for how to detect), // instead of using the emulator, one can use the in memory provider from Orleans: // // var orleans = builder.AddOrleans("my-app") diff --git a/src/Aspire.AppHost.Sdk/SDK/Sdk.in.targets b/src/Aspire.AppHost.Sdk/SDK/Sdk.in.targets index d18278658fc..dbf69351d39 100644 --- a/src/Aspire.AppHost.Sdk/SDK/Sdk.in.targets +++ b/src/Aspire.AppHost.Sdk/SDK/Sdk.in.targets @@ -15,7 +15,7 @@ - + false false + false false diff --git a/src/Aspire.Hosting.Azure.AppConfiguration/README.md b/src/Aspire.Hosting.Azure.AppConfiguration/README.md index 3fe0550defd..46c455b52e2 100644 --- a/src/Aspire.Hosting.Azure.AppConfiguration/README.md +++ b/src/Aspire.Hosting.Azure.AppConfiguration/README.md @@ -55,4 +55,4 @@ var myService = builder.AddProject() ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.AppContainers/ContainerAppContext.cs b/src/Aspire.Hosting.Azure.AppContainers/ContainerAppContext.cs index 3ba6954b84b..55d64589d26 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/ContainerAppContext.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/ContainerAppContext.cs @@ -22,7 +22,7 @@ public override void BuildContainerApp(AzureResourceInfrastructure infra) { _infrastructure = infra; // Write a fake parameter for the container app environment - // so azd knows the Dashboard URL - see https://github.com/dotnet/aspire/issues/8449. + // so azd knows the Dashboard URL - see https://github.com/microsoft/aspire/issues/8449. // This is temporary until a real fix can be made in azd. AllocateParameter(_containerAppEnvironmentContext.Environment.ContainerAppDomain); diff --git a/src/Aspire.Hosting.Azure.AppContainers/ContainerAppJobContext.cs b/src/Aspire.Hosting.Azure.AppContainers/ContainerAppJobContext.cs index 66a79e53916..32da3ed9de8 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/ContainerAppJobContext.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/ContainerAppJobContext.cs @@ -18,7 +18,7 @@ public override void BuildContainerApp(AzureResourceInfrastructure infra) { _infrastructure = infra; // Write a fake parameter for the container app environment - // so azd knows the Dashboard URL - see https://github.com/dotnet/aspire/issues/8449. + // so azd knows the Dashboard URL - see https://github.com/microsoft/aspire/issues/8449. // This is temporary until a real fix can be made in azd. AllocateParameter(_containerAppEnvironmentContext.Environment.ContainerAppDomain); diff --git a/src/Aspire.Hosting.Azure.AppService/README.md b/src/Aspire.Hosting.Azure.AppService/README.md index 70ff8bacae4..aeff7ee9b13 100644 --- a/src/Aspire.Hosting.Azure.AppService/README.md +++ b/src/Aspire.Hosting.Azure.AppService/README.md @@ -120,4 +120,4 @@ var appServiceEnvironment = builder.AddAzureAppServiceEnvironment("env") ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.ApplicationInsights/README.md b/src/Aspire.Hosting.Azure.ApplicationInsights/README.md index 4068f6a0924..e17594bf0fc 100644 --- a/src/Aspire.Hosting.Azure.ApplicationInsights/README.md +++ b/src/Aspire.Hosting.Azure.ApplicationInsights/README.md @@ -53,4 +53,4 @@ var myService = builder.AddProject() ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.CognitiveServices/README.md b/src/Aspire.Hosting.Azure.CognitiveServices/README.md index 5895e0613b7..656897496b7 100644 --- a/src/Aspire.Hosting.Azure.CognitiveServices/README.md +++ b/src/Aspire.Hosting.Azure.CognitiveServices/README.md @@ -78,8 +78,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://learn.microsoft.com/dotnet/api/overview/azure/ai.openai-readme -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.CosmosDB/README.md b/src/Aspire.Hosting.Azure.CosmosDB/README.md index 16f7000bea1..8efcdd7b12d 100644 --- a/src/Aspire.Hosting.Azure.CosmosDB/README.md +++ b/src/Aspire.Hosting.Azure.CosmosDB/README.md @@ -104,8 +104,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://learn.microsoft.com/azure/cosmos-db/nosql/sdk-dotnet-v3 -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.EventHubs/README.md b/src/Aspire.Hosting.Azure.EventHubs/README.md index 67e5b582bd5..d1d7d4a8e78 100644 --- a/src/Aspire.Hosting.Azure.EventHubs/README.md +++ b/src/Aspire.Hosting.Azure.EventHubs/README.md @@ -89,8 +89,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Microsoft.Azure.EventHubs/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.Functions/README.md b/src/Aspire.Hosting.Azure.Functions/README.md index 376ff172b7c..357ff30a739 100644 --- a/src/Aspire.Hosting.Azure.Functions/README.md +++ b/src/Aspire.Hosting.Azure.Functions/README.md @@ -49,4 +49,4 @@ app.Run(); ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.Kusto/README.md b/src/Aspire.Hosting.Azure.Kusto/README.md index cf8d470f99d..32d17942114 100644 --- a/src/Aspire.Hosting.Azure.Kusto/README.md +++ b/src/Aspire.Hosting.Azure.Kusto/README.md @@ -52,4 +52,4 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.Network/README.md b/src/Aspire.Hosting.Azure.Network/README.md index 3590fb1e102..6dbe2aa538b 100644 --- a/src/Aspire.Hosting.Azure.Network/README.md +++ b/src/Aspire.Hosting.Azure.Network/README.md @@ -158,4 +158,4 @@ storage.ConfigureInfrastructure(infra => ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.OperationalInsights/README.md b/src/Aspire.Hosting.Azure.OperationalInsights/README.md index b510d7160ed..2504c55b11f 100644 --- a/src/Aspire.Hosting.Azure.OperationalInsights/README.md +++ b/src/Aspire.Hosting.Azure.OperationalInsights/README.md @@ -57,4 +57,4 @@ var myService = builder.AddProject() ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.PostgreSQL/README.md b/src/Aspire.Hosting.Azure.PostgreSQL/README.md index 4d9c15ac609..7c7d34256f6 100644 --- a/src/Aspire.Hosting.Azure.PostgreSQL/README.md +++ b/src/Aspire.Hosting.Azure.PostgreSQL/README.md @@ -86,10 +86,10 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://www.npgsql.org/doc/basic-usage.html -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission._ diff --git a/src/Aspire.Hosting.Azure.Redis/README.md b/src/Aspire.Hosting.Azure.Redis/README.md index 577dfbb9014..4a373b361c3 100644 --- a/src/Aspire.Hosting.Azure.Redis/README.md +++ b/src/Aspire.Hosting.Azure.Redis/README.md @@ -74,10 +74,10 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://stackexchange.github.io/StackExchange.Redis/Basics -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd._ diff --git a/src/Aspire.Hosting.Azure.Search/README.md b/src/Aspire.Hosting.Azure.Search/README.md index 4926926f06f..6c1de884dd1 100644 --- a/src/Aspire.Hosting.Azure.Search/README.md +++ b/src/Aspire.Hosting.Azure.Search/README.md @@ -66,8 +66,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://learn.microsoft.com/azure/search/search-howto-dotnet-sdk -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.ServiceBus/README.md b/src/Aspire.Hosting.Azure.ServiceBus/README.md index 81378c19c65..c01d245bdc1 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/README.md +++ b/src/Aspire.Hosting.Azure.ServiceBus/README.md @@ -98,8 +98,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.Messaging.ServiceBus/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.SignalR/README.md b/src/Aspire.Hosting.Azure.SignalR/README.md index 80ad9a2804c..7b23c5feb1e 100644 --- a/src/Aspire.Hosting.Azure.SignalR/README.md +++ b/src/Aspire.Hosting.Azure.SignalR/README.md @@ -66,10 +66,10 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md * https://aspire.dev/integrations/cloud/azure/azure-signalr/ * https://learn.microsoft.com/azure/azure-signalr/signalr-overview ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs index 513ab11617b..5c01b66d442 100644 --- a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs +++ b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs @@ -334,7 +334,7 @@ public override void AddRoleAssignments(IAddRoleAssignmentsContext roleAssignmen $principalName = "$env:PRINCIPALNAME" $id = "$env:ID" - # Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926) + # Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926) Install-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser Import-Module SqlServer diff --git a/src/Aspire.Hosting.Azure.Sql/README.md b/src/Aspire.Hosting.Azure.Sql/README.md index 1c7ff4f939c..1d6c2c71873 100644 --- a/src/Aspire.Hosting.Azure.Sql/README.md +++ b/src/Aspire.Hosting.Azure.Sql/README.md @@ -117,8 +117,8 @@ var sqlSrv = builder.AddAzureSqlServer("sqlsrv") * https://learn.microsoft.com/dotnet/framework/data/adonet/sql/ * https://learn.microsoft.com/dotnet/api/system.data.sqlclient.sqlconnection -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.Storage/README.md b/src/Aspire.Hosting.Azure.Storage/README.md index f9a56af5fd2..e05ddae7f7b 100644 --- a/src/Aspire.Hosting.Azure.Storage/README.md +++ b/src/Aspire.Hosting.Azure.Storage/README.md @@ -200,8 +200,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure.WebPubSub/README.md b/src/Aspire.Hosting.Azure.WebPubSub/README.md index 180ebbd3a55..75a3f8c07bc 100644 --- a/src/Aspire.Hosting.Azure.WebPubSub/README.md +++ b/src/Aspire.Hosting.Azure.WebPubSub/README.md @@ -39,8 +39,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Azure/README.md b/src/Aspire.Hosting.Azure/README.md index 15892fc34b3..de894788486 100644 --- a/src/Aspire.Hosting.Azure/README.md +++ b/src/Aspire.Hosting.Azure/README.md @@ -54,4 +54,4 @@ var bicepResource = builder.AddBicepTemplate("bicep", "template.bicep") ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.DevTunnels/README.md b/src/Aspire.Hosting.DevTunnels/README.md index 40d85dfcc02..2ebb3c9eaef 100644 --- a/src/Aspire.Hosting.DevTunnels/README.md +++ b/src/Aspire.Hosting.DevTunnels/README.md @@ -214,6 +214,6 @@ The logging helps you verify that your tunnel configuration is working as expect ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire Contributions (improvements, clarifications, samples) are welcome. diff --git a/src/Aspire.Hosting.Docker/README.md b/src/Aspire.Hosting.Docker/README.md index f48b67ccd12..5aef119f093 100644 --- a/src/Aspire.Hosting.Docker/README.md +++ b/src/Aspire.Hosting.Docker/README.md @@ -26,4 +26,4 @@ aspire publish -o docker-compose-artifacts ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Foundry/README.md b/src/Aspire.Hosting.Foundry/README.md index 9ce378d9d32..6d94789d63a 100644 --- a/src/Aspire.Hosting.Foundry/README.md +++ b/src/Aspire.Hosting.Foundry/README.md @@ -169,8 +169,8 @@ In run mode, the agent runs locally with health check endpoints and OpenTelemetr * https://learn.microsoft.com/azure/ai-foundry/what-is-azure-ai-foundry * https://learn.microsoft.com/azure/ai-foundry/foundry-local/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Garnet/GarnetBuilderExtensions.cs b/src/Aspire.Hosting.Garnet/GarnetBuilderExtensions.cs index 1b6ab9f5ca1..af69e357a91 100644 --- a/src/Aspire.Hosting.Garnet/GarnetBuilderExtensions.cs +++ b/src/Aspire.Hosting.Garnet/GarnetBuilderExtensions.cs @@ -131,7 +131,7 @@ public static IResourceBuilder AddGarnet(this IDistributedApplic .WithImage(GarnetContainerImageTags.Image, GarnetContainerImageTags.Tag) .WithImageRegistry(GarnetContainerImageTags.Registry) .WithHealthCheck(healthCheckKey) - // see https://github.com/dotnet/aspire/issues/3838 for why the password is passed this way + // see https://github.com/microsoft/aspire/issues/3838 for why the password is passed this way .WithEntrypoint("/bin/sh") .WithEnvironment(context => { diff --git a/src/Aspire.Hosting.Garnet/README.md b/src/Aspire.Hosting.Garnet/README.md index 071ceb107b6..e08f1e28de9 100644 --- a/src/Aspire.Hosting.Garnet/README.md +++ b/src/Aspire.Hosting.Garnet/README.md @@ -50,10 +50,10 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE * https://github.com/microsoft/garnet/blob/main/README.md * https://stackexchange.github.io/StackExchange.Redis/Basics -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Garnet MIT License. Copyright (c) Microsoft Corporation.._ diff --git a/src/Aspire.Hosting.GitHub.Models/README.md b/src/Aspire.Hosting.GitHub.Models/README.md index c14e14cffab..d8c9edaa9b8 100644 --- a/src/Aspire.Hosting.GitHub.Models/README.md +++ b/src/Aspire.Hosting.GitHub.Models/README.md @@ -109,8 +109,8 @@ Check the [GitHub Models documentation](https://docs.github.com/en/github-models ## Additional documentation * https://docs.github.com/en/github-models -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.JavaScript/README.md b/src/Aspire.Hosting.JavaScript/README.md index 65ef7296ac0..42e16d0d5b9 100644 --- a/src/Aspire.Hosting.JavaScript/README.md +++ b/src/Aspire.Hosting.JavaScript/README.md @@ -25,9 +25,9 @@ builder.Build().Run(); ``` ## Additional documentation -https://github.com/dotnet/aspire-samples/tree/main/samples/aspire-with-javascript -https://github.com/dotnet/aspire-samples/tree/main/samples/aspire-with-node +https://github.com/microsoft/aspire-samples/tree/main/samples/aspire-with-javascript +https://github.com/microsoft/aspire-samples/tree/main/samples/aspire-with-node ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Kafka/README.md b/src/Aspire.Hosting.Kafka/README.md index cfa75f46fc1..f2a262b7a6a 100644 --- a/src/Aspire.Hosting.Kafka/README.md +++ b/src/Aspire.Hosting.Kafka/README.md @@ -44,4 +44,4 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Keycloak/README.md b/src/Aspire.Hosting.Keycloak/README.md index e65b270c7bb..8a27749d6ef 100644 --- a/src/Aspire.Hosting.Keycloak/README.md +++ b/src/Aspire.Hosting.Keycloak/README.md @@ -27,4 +27,4 @@ var myService = builder.AddProject() ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Kubernetes/Extensions/ResourceExtensions.cs b/src/Aspire.Hosting.Kubernetes/Extensions/ResourceExtensions.cs index cb3f7ec6c36..94ddb197454 100644 --- a/src/Aspire.Hosting.Kubernetes/Extensions/ResourceExtensions.cs +++ b/src/Aspire.Hosting.Kubernetes/Extensions/ResourceExtensions.cs @@ -145,7 +145,7 @@ internal static StatefulSet ToStatefulSet(this IResource resource, KubernetesRes // (matching the core framework's SetBothPortsEnvVariables behavior). This dedup // remains as a safety net for edge cases where multiple endpoints might still // resolve to the same port value. - // See: https://github.com/dotnet/aspire/issues/14029 + // See: https://github.com/microsoft/aspire/issues/14029 var addedPorts = new HashSet<(string Port, string Protocol)>(); foreach (var (_, mapping) in context.EndpointMappings) { diff --git a/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs b/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs index 737ad0b60b2..88fe890846e 100644 --- a/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs +++ b/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs @@ -180,7 +180,7 @@ private void ProcessEndpoints() // but reuse the http endpoint's HelmValue so no duplicate K8s port is generated. // This matches the core framework's SetBothPortsEnvVariables() behavior, // which skips DefaultHttpsEndpoint when setting HTTPS_PORTS. - // See: https://github.com/dotnet/aspire/issues/14029 + // See: https://github.com/microsoft/aspire/issues/14029 if (resource is ProjectResource projectResource && endpoint == projectResource.DefaultHttpsEndpoint) { diff --git a/src/Aspire.Hosting.Kubernetes/README.md b/src/Aspire.Hosting.Kubernetes/README.md index 93edf815473..07a9022a188 100644 --- a/src/Aspire.Hosting.Kubernetes/README.md +++ b/src/Aspire.Hosting.Kubernetes/README.md @@ -26,4 +26,4 @@ aspire publish -o k8s-artifacts ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Maui/README.md b/src/Aspire.Hosting.Maui/README.md index d1e290685da..c3985fb704e 100644 --- a/src/Aspire.Hosting.Maui/README.md +++ b/src/Aspire.Hosting.Maui/README.md @@ -197,4 +197,4 @@ adb devices ## Feedback & Issues -Please file issues at https://github.com/dotnet/aspire/issues +Please file issues at https://github.com/microsoft/aspire/issues diff --git a/src/Aspire.Hosting.Milvus/MilvusContainerImageTags.cs b/src/Aspire.Hosting.Milvus/MilvusContainerImageTags.cs index 2edbb5e997a..8291d202200 100644 --- a/src/Aspire.Hosting.Milvus/MilvusContainerImageTags.cs +++ b/src/Aspire.Hosting.Milvus/MilvusContainerImageTags.cs @@ -11,7 +11,7 @@ internal static class MilvusContainerImageTags /// milvusdb/milvus public const string Image = "milvusdb/milvus"; - // Note that when trying to update to v2.6.0 we hit https://github.com/dotnet/aspire/issues/11184 + // Note that when trying to update to v2.6.0 we hit https://github.com/microsoft/aspire/issues/11184 /// v2.5.27 public const string Tag = "v2.5.27"; diff --git a/src/Aspire.Hosting.Milvus/README.md b/src/Aspire.Hosting.Milvus/README.md index 722c1a0d619..dd5151ba80a 100644 --- a/src/Aspire.Hosting.Milvus/README.md +++ b/src/Aspire.Hosting.Milvus/README.md @@ -54,6 +54,6 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Milvus and the Milvus logo are used with permission from the Milvus project. All rights reserved by LF AI & Data foundation._ diff --git a/src/Aspire.Hosting.MongoDB/README.md b/src/Aspire.Hosting.MongoDB/README.md index 83c2b27bb8a..abc2733a942 100644 --- a/src/Aspire.Hosting.MongoDB/README.md +++ b/src/Aspire.Hosting.MongoDB/README.md @@ -57,4 +57,4 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.MySql/README.md b/src/Aspire.Hosting.MySql/README.md index 6e5e47ed939..5838d468fdb 100644 --- a/src/Aspire.Hosting.MySql/README.md +++ b/src/Aspire.Hosting.MySql/README.md @@ -58,4 +58,4 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Nats/README.md b/src/Aspire.Hosting.Nats/README.md index e50f18158b2..60d060d4ef2 100644 --- a/src/Aspire.Hosting.Nats/README.md +++ b/src/Aspire.Hosting.Nats/README.md @@ -47,4 +47,4 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.OpenAI/README.md b/src/Aspire.Hosting.OpenAI/README.md index 16d8406f5ac..ce258d8ff51 100644 --- a/src/Aspire.Hosting.OpenAI/README.md +++ b/src/Aspire.Hosting.OpenAI/README.md @@ -145,8 +145,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Additional documentation * https://platform.openai.com/docs/models -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Oracle/README.md b/src/Aspire.Hosting.Oracle/README.md index 1e1a6238e0d..0691dbfd755 100644 --- a/src/Aspire.Hosting.Oracle/README.md +++ b/src/Aspire.Hosting.Oracle/README.md @@ -58,4 +58,4 @@ https://aspire.dev/integrations/databases/oracle/ ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Orleans/README.md b/src/Aspire.Hosting.Orleans/README.md index 5eebe9f385a..2f46633933b 100644 --- a/src/Aspire.Hosting.Orleans/README.md +++ b/src/Aspire.Hosting.Orleans/README.md @@ -37,4 +37,4 @@ https://learn.microsoft.com/dotnet/orleans/ ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.PostgreSQL/README.md b/src/Aspire.Hosting.PostgreSQL/README.md index f13264b0087..ece699169ec 100644 --- a/src/Aspire.Hosting.PostgreSQL/README.md +++ b/src/Aspire.Hosting.PostgreSQL/README.md @@ -72,6 +72,6 @@ https://aspire.dev/integrations/databases/efcore/postgresql/ ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission._ diff --git a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs index 517bba26aba..986748cb603 100644 --- a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs +++ b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs @@ -91,7 +91,7 @@ public static IResourceBuilder AddQdrant(this IDistributed .WithUrlForEndpoint(QdrantServerResource.PrimaryEndpointName, c => { c.DisplayText = "Qdrant (GRPC)"; - // https://github.com/dotnet/aspire/issues/8809 + // https://github.com/microsoft/aspire/issues/8809 c.DisplayLocation = UrlDisplayLocation.DetailsOnly; }) .WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, c => c.DisplayText = "Qdrant (HTTP)") diff --git a/src/Aspire.Hosting.Qdrant/README.md b/src/Aspire.Hosting.Qdrant/README.md index 218f208fe67..4c682427971 100644 --- a/src/Aspire.Hosting.Qdrant/README.md +++ b/src/Aspire.Hosting.Qdrant/README.md @@ -49,6 +49,6 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _Qdrant, and the Qdrant logo are trademarks or registered trademarks of Qdrant Solutions GmbH of Germany, and used with their permission._ diff --git a/src/Aspire.Hosting.RabbitMQ/README.md b/src/Aspire.Hosting.RabbitMQ/README.md index 2e33a0f7312..513fbbb2fc3 100644 --- a/src/Aspire.Hosting.RabbitMQ/README.md +++ b/src/Aspire.Hosting.RabbitMQ/README.md @@ -47,4 +47,4 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Redis/README.md b/src/Aspire.Hosting.Redis/README.md index a8397835d4e..ba86ab3d722 100644 --- a/src/Aspire.Hosting.Redis/README.md +++ b/src/Aspire.Hosting.Redis/README.md @@ -48,6 +48,6 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd._ diff --git a/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs b/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs index ad56fcb4721..e65ee998e83 100644 --- a/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs +++ b/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs @@ -95,7 +95,7 @@ public static IResourceBuilder AddRedis( .WithImage(RedisContainerImageTags.Image, RedisContainerImageTags.Tag) .WithImageRegistry(RedisContainerImageTags.Registry) .WithHealthCheck(healthCheckKey) - // see https://github.com/dotnet/aspire/issues/3838 for why the password is passed this way + // see https://github.com/microsoft/aspire/issues/3838 for why the password is passed this way .WithEntrypoint("/bin/sh") .WithEnvironment(context => { diff --git a/src/Aspire.Hosting.Seq/README.md b/src/Aspire.Hosting.Seq/README.md index b83a5c90e1f..c88201601c6 100644 --- a/src/Aspire.Hosting.Seq/README.md +++ b/src/Aspire.Hosting.Seq/README.md @@ -45,4 +45,4 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.SqlServer/README.md b/src/Aspire.Hosting.SqlServer/README.md index b1b23da76ee..c9d46fa643c 100644 --- a/src/Aspire.Hosting.SqlServer/README.md +++ b/src/Aspire.Hosting.SqlServer/README.md @@ -58,4 +58,4 @@ https://aspire.dev/integrations/databases/efcore/sql-server/ ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Valkey/README.md b/src/Aspire.Hosting.Valkey/README.md index 8897fb5356a..2d92bd6cd73 100644 --- a/src/Aspire.Hosting.Valkey/README.md +++ b/src/Aspire.Hosting.Valkey/README.md @@ -45,8 +45,8 @@ Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPE * https://valkey.io * https://github.com/valkey-io/valkey/blob/unstable/README.md * https://stackexchange.github.io/StackExchange.Redis/Basics -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting.Valkey/ValkeyBuilderExtensions.cs b/src/Aspire.Hosting.Valkey/ValkeyBuilderExtensions.cs index 716f94b193c..43e4ffd12b4 100644 --- a/src/Aspire.Hosting.Valkey/ValkeyBuilderExtensions.cs +++ b/src/Aspire.Hosting.Valkey/ValkeyBuilderExtensions.cs @@ -145,7 +145,7 @@ public static IResourceBuilder AddValkey( .WithImage(ValkeyContainerImageTags.Image, ValkeyContainerImageTags.Tag) .WithImageRegistry(ValkeyContainerImageTags.Registry) .WithHealthCheck(healthCheckKey) - // see https://github.com/dotnet/aspire/issues/3838 for why the password is passed this way + // see https://github.com/microsoft/aspire/issues/3838 for why the password is passed this way .WithEntrypoint("/bin/sh") .WithEnvironment(context => { diff --git a/src/Aspire.Hosting.Yarp/README.md b/src/Aspire.Hosting.Yarp/README.md index 997d40767ec..429ccd7efec 100644 --- a/src/Aspire.Hosting.Yarp/README.md +++ b/src/Aspire.Hosting.Yarp/README.md @@ -183,4 +183,4 @@ builder.AddYarp("gateway") ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs b/src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs index c7de42b9a5a..bb27fd0b8f7 100644 --- a/src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs +++ b/src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs @@ -131,7 +131,7 @@ internal static void AddLifeCycleCommands(this IResource resource) } // Treat "Unknown" as stopped so the command to start the resource is available when "Unknown". - // There is a situation where a container can be stopped with this state: https://github.com/dotnet/aspire/issues/5977 + // There is a situation where a container can be stopped with this state: https://github.com/microsoft/aspire/issues/5977 static bool IsStopped(string? state) => KnownResourceStates.TerminalStates.Contains(state) || state == KnownResourceStates.NotStarted || state == "Unknown"; static bool IsStopping(string? state) => state == KnownResourceStates.Stopping; static bool IsStarting(string? state) => state == KnownResourceStates.Starting; diff --git a/src/Aspire.Hosting/Dashboard/proto/dashboard_service.proto b/src/Aspire.Hosting/Dashboard/proto/dashboard_service.proto index a7f7fe37998..2cd238327f4 100644 --- a/src/Aspire.Hosting/Dashboard/proto/dashboard_service.proto +++ b/src/Aspire.Hosting/Dashboard/proto/dashboard_service.proto @@ -186,12 +186,12 @@ message ResourceRelationship { message ResourceProperty { // Name of the data item, e.g. "container.id", "executable.pid", "project.path", ... string name = 1; - // TODO move display_name to reference data, sent once when the connection starts (https://github.com/dotnet/aspire/issues/1644) + // TODO move display_name to reference data, sent once when the connection starts (https://github.com/microsoft/aspire/issues/1644) // Optional display name, may be localized optional string display_name = 2; // The data value. May be null, a number, a string, a boolean, a dictionary of values (Struct), or a list of values (ValueList). google.protobuf.Value value = 3; - // TODO move is_sensitive to reference data, sent once when the connection starts (https://github.com/dotnet/aspire/issues/1644) + // TODO move is_sensitive to reference data, sent once when the connection starts (https://github.com/microsoft/aspire/issues/1644) // Whether the value is sensitive and should be masked in the UI by default. // Defaults to false. When true, the user must explicitly unmask the value to view it. optional bool is_sensitive = 4; diff --git a/src/Aspire.Hosting/Dcp/DcpExecutor.cs b/src/Aspire.Hosting/Dcp/DcpExecutor.cs index fa1709bdd9e..05eb095d1e1 100644 --- a/src/Aspire.Hosting/Dcp/DcpExecutor.cs +++ b/src/Aspire.Hosting/Dcp/DcpExecutor.cs @@ -277,7 +277,7 @@ public async Task StopAsync(CancellationToken cancellationToken) // This is just a perf optimization, so we do not care that much if this call fails. // There is not much difference for single app run, but for tests that tend to launch multiple instances // of app host from the same process, the gain from programmatic orchestrator shutdown is significant - // See https://github.com/dotnet/aspire/issues/6561 for more info. + // See https://github.com/microsoft/aspire/issues/6561 for more info. await _kubernetesService.StopServerAsync(Model.ResourceCleanup.Full, cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) @@ -1644,7 +1644,7 @@ private async Task CreateExecutableAsync(RenderedModelResource er, ILogger resou var spec = exe.Spec; // Don't create an args collection unless needed. A null args collection means a project run by the will use args provided by the launch profile. - // https://github.com/dotnet/aspire/blob/main/docs/specs/IDE-execution.md#launch-profile-processing-project-launch-configuration + // https://github.com/microsoft/aspire/blob/main/docs/specs/IDE-execution.md#launch-profile-processing-project-launch-configuration spec.Args = null; // An executable can be restarted so args must be reset to an empty state. @@ -1817,7 +1817,7 @@ private async Task CreateExecutableAsync(RenderedModelResource er, ILogger resou // Launch args is the final list of args that are displayed in the UI and possibly added to the executable spec. // They're built from app host resource model args and any args in the effective launch profile. // Follows behavior in the IDE execution spec when in IDE execution mode: - // https://github.com/dotnet/aspire/blob/main/docs/specs/IDE-execution.md#project-launch-configuration-type-project + // https://github.com/microsoft/aspire/blob/main/docs/specs/IDE-execution.md#project-launch-configuration-type-project var launchArgs = new List<(string Value, bool IsSensitive, bool Executable, bool Display)>(); // If the executable is a project then include any command line args from the launch profile. diff --git a/src/Aspire.Hosting/DistributedApplicationBuilder.cs b/src/Aspire.Hosting/DistributedApplicationBuilder.cs index 3edef2868ab..5807fc48acf 100644 --- a/src/Aspire.Hosting/DistributedApplicationBuilder.cs +++ b/src/Aspire.Hosting/DistributedApplicationBuilder.cs @@ -211,7 +211,7 @@ public DistributedApplicationBuilder(DistributedApplicationOptions options) } // This is so that we can see certificate errors in the resource server in the console logs. - // See: https://github.com/dotnet/aspire/issues/2914 + // See: https://github.com/microsoft/aspire/issues/2914 _innerBuilder.Logging.AddFilter("Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer", LogLevel.Warning); // Add the logging configuration again to allow the user to override the defaults diff --git a/src/Aspire.Hosting/DotnetToolResourceExtensions.cs b/src/Aspire.Hosting/DotnetToolResourceExtensions.cs index 13602cc8b9a..3328e2acabd 100644 --- a/src/Aspire.Hosting/DotnetToolResourceExtensions.cs +++ b/src/Aspire.Hosting/DotnetToolResourceExtensions.cs @@ -92,7 +92,7 @@ void BuildToolExecArguments(CommandLineArgsCallbackContext x) x.Args.Add(ArgumentSeparator); } - //TODO: Move to WithConfigurationFinalizer once merged - https://github.com/dotnet/aspire/pull/13200 + //TODO: Move to WithConfigurationFinalizer once merged - https://github.com/microsoft/aspire/pull/13200 async Task BeforeResourceStarted(T resource, BeforeResourceStartedEvent evt, CancellationToken ct) { var rns = evt.Services.GetRequiredService(); diff --git a/src/Aspire.Hosting/Exec/ExecResourceManager.cs b/src/Aspire.Hosting/Exec/ExecResourceManager.cs index 0a3db50c28b..eec551c2856 100644 --- a/src/Aspire.Hosting/Exec/ExecResourceManager.cs +++ b/src/Aspire.Hosting/Exec/ExecResourceManager.cs @@ -103,7 +103,7 @@ public async IAsyncEnumerable StreamExecResourceLogs([EnumeratorC { await _resourceNotificationService.WaitForResourceAsync(execResource!.Name, targetStates: KnownResourceStates.TerminalStates, cancellationToken).ConfigureAwait(false); - // hack: https://github.com/dotnet/aspire/issues/10245 + // hack: https://github.com/microsoft/aspire/issues/10245 // workarounds the race-condition between streaming all logs from the resource, and resource completion await Task.Delay(1000, CancellationToken.None).ConfigureAwait(false); diff --git a/src/Aspire.Hosting/Health/ResourceHealthCheckService.cs b/src/Aspire.Hosting/Health/ResourceHealthCheckService.cs index c6cf6d3395b..857c215654c 100644 --- a/src/Aspire.Hosting/Health/ResourceHealthCheckService.cs +++ b/src/Aspire.Hosting/Health/ResourceHealthCheckService.cs @@ -379,7 +379,7 @@ internal async Task DelayAsync(ResourceEvent? currentEvent, TimeSpan delay } // Don't throw to avoid writing the thrown exception to the debug console. - // See https://github.com/dotnet/aspire/issues/7486 + // See https://github.com/microsoft/aspire/issues/7486 await delayInterruptedTask.WaitAsync(delay, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing); var delayInterrupted = delayInterruptedTask.IsCompletedSuccessfully == true; diff --git a/src/Aspire.Hosting/README.md b/src/Aspire.Hosting/README.md index 6d1e2e54777..442a3000465 100644 --- a/src/Aspire.Hosting/README.md +++ b/src/Aspire.Hosting/README.md @@ -24,8 +24,8 @@ Key concepts include: Aspire's approach ensures flexibility, strong tooling support, and clear separation between modeling, orchestration, and execution of distributed .NET applications. -For the full details and specification, see the [App Model document](https://github.com/dotnet/aspire/blob/main/docs/specs/appmodel.md). +For the full details and specification, see the [App Model document](https://github.com/microsoft/aspire/blob/main/docs/specs/appmodel.md). ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj b/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj index 5428797b2cf..edcfe1a96af 100644 --- a/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj +++ b/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Aspire.ProjectTemplates/templates/aspire-py-starter/frontend/src/App.tsx b/src/Aspire.ProjectTemplates/templates/aspire-py-starter/frontend/src/App.tsx index b9b5a1b10ae..869f34c5cac 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-py-starter/frontend/src/App.tsx +++ b/src/Aspire.ProjectTemplates/templates/aspire-py-starter/frontend/src/App.tsx @@ -166,7 +166,7 @@ function App() { Learn more about Aspire (opens in new tab) (opens in new tab) * https://aspire.dev/integrations/cloud/azure/azure-event-hubs/ * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Microsoft.Azure.EventHubs/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Azure.Messaging.ServiceBus/README.md b/src/Components/Aspire.Azure.Messaging.ServiceBus/README.md index 3015206b1e2..c56b355630b 100644 --- a/src/Components/Aspire.Azure.Messaging.ServiceBus/README.md +++ b/src/Components/Aspire.Azure.Messaging.ServiceBus/README.md @@ -141,8 +141,8 @@ builder.AddAzureServiceBusClient("sb"); * https://aspire.dev/integrations/cloud/azure/azure-service-bus/ * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.Messaging.ServiceBus/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Azure.Messaging.WebPubSub/README.md b/src/Components/Aspire.Azure.Messaging.WebPubSub/README.md index 784da04f37e..9d43999064d 100644 --- a/src/Components/Aspire.Azure.Messaging.WebPubSub/README.md +++ b/src/Components/Aspire.Azure.Messaging.WebPubSub/README.md @@ -129,8 +129,8 @@ builder.AddAzureWebPubSubServiceClient("wps"); ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/webpubsub/Azure.Messaging.WebPubSub/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL/README.md b/src/Components/Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL/README.md index dbda3a4b40f..216630e8a57 100644 --- a/src/Components/Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL/README.md +++ b/src/Components/Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL/README.md @@ -151,10 +151,10 @@ builder.EnrichAzureNpgsqlDbContext(); ## Additional documentation * https://learn.microsoft.com/ef/core/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission._ diff --git a/src/Components/Aspire.Azure.Npgsql/README.md b/src/Components/Aspire.Azure.Npgsql/README.md index a8c4d7dd899..aaa496ff31d 100644 --- a/src/Components/Aspire.Azure.Npgsql/README.md +++ b/src/Components/Aspire.Azure.Npgsql/README.md @@ -136,10 +136,10 @@ builder.AddAzureNpgsqlDataSource("db", configureDataSourceBuilder: * https://aspire.dev/integrations/cloud/azure/azure-postgresql/ * https://www.npgsql.org/doc/basic-usage.html -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission._ diff --git a/src/Components/Aspire.Azure.Search.Documents/README.md b/src/Components/Aspire.Azure.Search.Documents/README.md index 9784aa920d5..c69f7d8d859 100644 --- a/src/Components/Aspire.Azure.Search.Documents/README.md +++ b/src/Components/Aspire.Azure.Search.Documents/README.md @@ -154,8 +154,8 @@ builder.AddAzureSearchClient("search"); ## Additional documentation * https://learn.microsoft.com/azure/search/search-howto-dotnet-sdk -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Azure.Security.KeyVault/README.md b/src/Components/Aspire.Azure.Security.KeyVault/README.md index b0f0a0fb4ed..1fee31351ef 100644 --- a/src/Components/Aspire.Azure.Security.KeyVault/README.md +++ b/src/Components/Aspire.Azure.Security.KeyVault/README.md @@ -182,8 +182,8 @@ builder.AddAzureKeyVaultClient("secrets"); ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Secrets/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Azure.Storage.Blobs/README.md b/src/Components/Aspire.Azure.Storage.Blobs/README.md index ecfb252c086..22bd0b1fa48 100644 --- a/src/Components/Aspire.Azure.Storage.Blobs/README.md +++ b/src/Components/Aspire.Azure.Storage.Blobs/README.md @@ -142,8 +142,8 @@ builder.AddAzureBlobServiceClient("blobs"); ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Azure.Storage.Files.DataLake/README.md b/src/Components/Aspire.Azure.Storage.Files.DataLake/README.md index aa1654970ad..80c8ec049b3 100644 --- a/src/Components/Aspire.Azure.Storage.Files.DataLake/README.md +++ b/src/Components/Aspire.Azure.Storage.Files.DataLake/README.md @@ -157,8 +157,8 @@ builder.AddAzureDataLakeFileSystemClient("data-lake-file-system"); ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Files.DataLake/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Azure.Storage.Queues/README.md b/src/Components/Aspire.Azure.Storage.Queues/README.md index a646abad5e7..fb80d80bbdf 100644 --- a/src/Components/Aspire.Azure.Storage.Queues/README.md +++ b/src/Components/Aspire.Azure.Storage.Queues/README.md @@ -142,8 +142,8 @@ builder.AddAzureQueueServiceClient("queue"); ## Additional documentation * https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/README.md -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Confluent.Kafka/README.md b/src/Components/Aspire.Confluent.Kafka/README.md index 3d1d26568ce..e98df32c9c8 100644 --- a/src/Components/Aspire.Confluent.Kafka/README.md +++ b/src/Components/Aspire.Confluent.Kafka/README.md @@ -156,8 +156,8 @@ builder.AddKafkaConsumer("messaging"); ## Additional documentation * https://docs.confluent.io/kafka-clients/dotnet/current/overview.html -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Keycloak.Authentication/README.md b/src/Components/Aspire.Keycloak.Authentication/README.md index a4e965bba53..d781aff035a 100644 --- a/src/Components/Aspire.Keycloak.Authentication/README.md +++ b/src/Components/Aspire.Keycloak.Authentication/README.md @@ -100,8 +100,8 @@ builder.Services.AddAuthentication(oidcScheme) ## Additional documentation * https://www.keycloak.org/getting-started/getting-started-docker -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Microsoft.Azure.Cosmos/README.md b/src/Components/Aspire.Microsoft.Azure.Cosmos/README.md index 0f6f5a72953..f881a2a5ca1 100644 --- a/src/Components/Aspire.Microsoft.Azure.Cosmos/README.md +++ b/src/Components/Aspire.Microsoft.Azure.Cosmos/README.md @@ -152,8 +152,8 @@ builder.AddAzureCosmosClient("cosmos"); ## Additional documentation * https://learn.microsoft.com/azure/cosmos-db/nosql/sdk-dotnet-v3 -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Microsoft.Azure.StackExchangeRedis/README.md b/src/Components/Aspire.Microsoft.Azure.StackExchangeRedis/README.md index c6d4f28def9..c9ed43cf493 100644 --- a/src/Components/Aspire.Microsoft.Azure.StackExchangeRedis/README.md +++ b/src/Components/Aspire.Microsoft.Azure.StackExchangeRedis/README.md @@ -113,6 +113,6 @@ This will also require your Azure environment to be configured by following [the ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd._ diff --git a/src/Components/Aspire.Microsoft.Data.SqlClient/README.md b/src/Components/Aspire.Microsoft.Data.SqlClient/README.md index f9194d2f3f1..19c715bdda3 100644 --- a/src/Components/Aspire.Microsoft.Data.SqlClient/README.md +++ b/src/Components/Aspire.Microsoft.Data.SqlClient/README.md @@ -112,8 +112,8 @@ builder.AddSqlServerClient("sqldata"); * https://learn.microsoft.com/dotnet/framework/data/adonet/sql/ * https://learn.microsoft.com/dotnet/api/system.data.sqlclient.sqlconnection -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Microsoft.EntityFrameworkCore.Cosmos/README.md b/src/Components/Aspire.Microsoft.EntityFrameworkCore.Cosmos/README.md index 5c841d60216..7175ec6f938 100644 --- a/src/Components/Aspire.Microsoft.EntityFrameworkCore.Cosmos/README.md +++ b/src/Components/Aspire.Microsoft.EntityFrameworkCore.Cosmos/README.md @@ -144,8 +144,8 @@ builder.AddCosmosDbContext("cosmos", "mydb"); ## Additional documentation * https://learn.microsoft.com/ef/core/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Microsoft.EntityFrameworkCore.SqlServer/README.md b/src/Components/Aspire.Microsoft.EntityFrameworkCore.SqlServer/README.md index cb71ab10be4..8ec812e3dd1 100644 --- a/src/Components/Aspire.Microsoft.EntityFrameworkCore.SqlServer/README.md +++ b/src/Components/Aspire.Microsoft.EntityFrameworkCore.SqlServer/README.md @@ -128,8 +128,8 @@ builder.AddSqlServerDbContext("sqldata"); ## Additional documentation * https://learn.microsoft.com/ef/core/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md index 7ec190aa7bf..9fb595bd577 100644 --- a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md +++ b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md @@ -158,8 +158,8 @@ builder.AddAzureAppConfiguration("appConfig"); ## Additional documentation * https://learn.microsoft.com/azure/azure-app-configuration/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Milvus.Client/README.md b/src/Components/Aspire.Milvus.Client/README.md index 5ba8b45594b..5f588dc8e6c 100644 --- a/src/Components/Aspire.Milvus.Client/README.md +++ b/src/Components/Aspire.Milvus.Client/README.md @@ -98,10 +98,10 @@ builder.AddMilvusClient("milvus"); ## Additional documentation * https://github.com/milvus-io/milvus-sdk-csharp -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Milvus and the Milvus logo are used with permission from the Milvus project. All rights reserved by LF AI & Data foundation._ diff --git a/src/Components/Aspire.MongoDB.Driver/README.md b/src/Components/Aspire.MongoDB.Driver/README.md index e07db579fe0..a3f77ec078a 100644 --- a/src/Components/Aspire.MongoDB.Driver/README.md +++ b/src/Components/Aspire.MongoDB.Driver/README.md @@ -112,8 +112,8 @@ builder.AddMongoDBClient("mongodb"); ## Additional documentation * https://www.mongodb.com/docs/drivers/csharp/current/quick-start/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.MongoDB.EntityFrameworkCore/README.md b/src/Components/Aspire.MongoDB.EntityFrameworkCore/README.md index b48ada5f2e0..a11bf2ca8a7 100644 --- a/src/Components/Aspire.MongoDB.EntityFrameworkCore/README.md +++ b/src/Components/Aspire.MongoDB.EntityFrameworkCore/README.md @@ -150,8 +150,8 @@ Note: When using `AddDatabase` in the AppHost, the database name is included in * https://learn.microsoft.com/ef/core/ * https://www.mongodb.com/docs/entity-framework/current/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.MySqlConnector/README.md b/src/Components/Aspire.MySqlConnector/README.md index f175cfbe3af..116f5523c63 100644 --- a/src/Components/Aspire.MySqlConnector/README.md +++ b/src/Components/Aspire.MySqlConnector/README.md @@ -108,8 +108,8 @@ builder.AddMySqlDataSource("mysqldb"); ## Additional documentation * https://mysqlconnector.net/tutorials/basic-api/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.NATS.Net/README.md b/src/Components/Aspire.NATS.Net/README.md index 129b2570741..e30ef85fc3b 100644 --- a/src/Components/Aspire.NATS.Net/README.md +++ b/src/Components/Aspire.NATS.Net/README.md @@ -109,8 +109,8 @@ builder.AddNatsClient("nats"); ## Additional documentation * https://nats-io.github.io/nats.net.v2/documentation/intro.html -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Npgsql.EntityFrameworkCore.PostgreSQL/README.md b/src/Components/Aspire.Npgsql.EntityFrameworkCore.PostgreSQL/README.md index 7d8687b05d2..d5ba24ae928 100644 --- a/src/Components/Aspire.Npgsql.EntityFrameworkCore.PostgreSQL/README.md +++ b/src/Components/Aspire.Npgsql.EntityFrameworkCore.PostgreSQL/README.md @@ -128,10 +128,10 @@ builder.AddNpgsqlDbContext("postgresdb"); ## Additional documentation * https://learn.microsoft.com/ef/core/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission._ diff --git a/src/Components/Aspire.Npgsql/README.md b/src/Components/Aspire.Npgsql/README.md index 43a1550f63b..f046d0e63db 100644 --- a/src/Components/Aspire.Npgsql/README.md +++ b/src/Components/Aspire.Npgsql/README.md @@ -108,10 +108,10 @@ builder.AddNpgsqlDataSource("postgresdb"); ## Additional documentation * https://www.npgsql.org/doc/basic-usage.html -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission._ diff --git a/src/Components/Aspire.OpenAI/README.md b/src/Components/Aspire.OpenAI/README.md index ecfc4ea05c8..d7f079fad66 100644 --- a/src/Components/Aspire.OpenAI/README.md +++ b/src/Components/Aspire.OpenAI/README.md @@ -126,8 +126,8 @@ or by setting the "OPENAI_EXPERIMENTAL_ENABLE_OPEN_TELEMETRY" environment variab ## Additional documentation * https://github.com/openai/openai-dotnet -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Oracle.EntityFrameworkCore/README.md b/src/Components/Aspire.Oracle.EntityFrameworkCore/README.md index 947dced6fba..bc9d2434bd9 100644 --- a/src/Components/Aspire.Oracle.EntityFrameworkCore/README.md +++ b/src/Components/Aspire.Oracle.EntityFrameworkCore/README.md @@ -126,8 +126,8 @@ builder.AddOracleDatabaseDbContext("freepdb1"); ## Additional documentation * https://learn.microsoft.com/ef/core/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/README.md b/src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/README.md index ba1d0d44b7f..824414adac0 100644 --- a/src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/README.md +++ b/src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/README.md @@ -131,8 +131,8 @@ builder.AddMySqlDbContext("mysqldb"); ## Additional documentation * https://learn.microsoft.com/ef/core/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Qdrant.Client/README.md b/src/Components/Aspire.Qdrant.Client/README.md index c725d026127..a99cd1890b3 100644 --- a/src/Components/Aspire.Qdrant.Client/README.md +++ b/src/Components/Aspire.Qdrant.Client/README.md @@ -98,10 +98,10 @@ builder.AddQdrantClient("qdrant"); ## Additional documentation * https://github.com/qdrant/qdrant-dotnet -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _Qdrant, and the Qdrant logo are trademarks or registered trademarks of Qdrant Solutions GmbH of Germany, and used with their permission._ diff --git a/src/Components/Aspire.RabbitMQ.Client/AspireRabbitMQExtensions.cs b/src/Components/Aspire.RabbitMQ.Client/AspireRabbitMQExtensions.cs index f9bf2248301..fd34fd6f7a0 100644 --- a/src/Components/Aspire.RabbitMQ.Client/AspireRabbitMQExtensions.cs +++ b/src/Components/Aspire.RabbitMQ.Client/AspireRabbitMQExtensions.cs @@ -234,7 +234,7 @@ private static IConnection CreateConnection(IConnectionFactory factory, int retr AddRabbitMQExceptionTags(connectAttemptActivity, ex); throw; } - }, factory).AsTask().GetAwaiter().GetResult(); // see https://github.com/dotnet/aspire/issues/565 + }, factory).AsTask().GetAwaiter().GetResult(); // see https://github.com/microsoft/aspire/issues/565 #endif } diff --git a/src/Components/Aspire.RabbitMQ.Client/README.md b/src/Components/Aspire.RabbitMQ.Client/README.md index 1744c38f53b..42176b27cf7 100644 --- a/src/Components/Aspire.RabbitMQ.Client/README.md +++ b/src/Components/Aspire.RabbitMQ.Client/README.md @@ -115,8 +115,8 @@ builder.AddRabbitMQClient("messaging"); ## Additional documentation * https://rabbitmq.github.io/rabbitmq-dotnet-client/ -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.Seq/README.md b/src/Components/Aspire.Seq/README.md index 770cb505b80..eb2c700b863 100644 --- a/src/Components/Aspire.Seq/README.md +++ b/src/Components/Aspire.Seq/README.md @@ -99,8 +99,8 @@ Seq is not part of the Aspire deployment manifest. It is recommended to set up a ## Additional documentation * https://docs.datalust.co/docs/the-seq-query-language -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire diff --git a/src/Components/Aspire.StackExchange.Redis.DistributedCaching/README.md b/src/Components/Aspire.StackExchange.Redis.DistributedCaching/README.md index f1df0e39d52..0908870c1ea 100644 --- a/src/Components/Aspire.StackExchange.Redis.DistributedCaching/README.md +++ b/src/Components/Aspire.StackExchange.Redis.DistributedCaching/README.md @@ -140,10 +140,10 @@ builder.AddRedisDistributedCache("cache"); ## Additional documentation * https://learn.microsoft.com/aspnet/core/performance/caching/distributed -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd._ diff --git a/src/Components/Aspire.StackExchange.Redis.OutputCaching/README.md b/src/Components/Aspire.StackExchange.Redis.OutputCaching/README.md index 47c256a94a8..956771271d6 100644 --- a/src/Components/Aspire.StackExchange.Redis.OutputCaching/README.md +++ b/src/Components/Aspire.StackExchange.Redis.OutputCaching/README.md @@ -125,10 +125,10 @@ builder.AddRedisOutputCache("cache"); ## Additional documentation * https://learn.microsoft.com/aspnet/core/performance/caching/output -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd._ diff --git a/src/Components/Aspire.StackExchange.Redis/README.md b/src/Components/Aspire.StackExchange.Redis/README.md index 602dd4db8fe..1dd2d62d902 100644 --- a/src/Components/Aspire.StackExchange.Redis/README.md +++ b/src/Components/Aspire.StackExchange.Redis/README.md @@ -122,10 +122,10 @@ builder.AddRedisClient("cache"); ## Additional documentation * https://stackexchange.github.io/StackExchange.Redis/Basics -* https://github.com/dotnet/aspire/tree/main/src/Components/README.md +* https://github.com/microsoft/aspire/tree/main/src/Components/README.md ## Feedback & contributing -https://github.com/dotnet/aspire +https://github.com/microsoft/aspire _*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd._ diff --git a/src/Components/README.md b/src/Components/README.md index dde3abd3c39..1095f3baab6 100644 --- a/src/Components/README.md +++ b/src/Components/README.md @@ -4,15 +4,15 @@ Aspire client integrations are classic .NET NuGet packages which are designed as ## Contribution guidelines -We aim to have a diverse set of high quality Aspire client integrations, making it easy to pick from many different technologies when building Aspire apps. We expect to continue to add more client integrations, and we welcome contributions of others, but we explicitly don't want to include every possible client integration. The set will be gently curated: in order to make sure that client integrations are useful and dependable, we have some broad criteria below for client integrations contributed to dotnet/aspire. These will likely evolve over time based on feedback, but we expect some requirements (such as actively supported) to remain firm: +We aim to have a diverse set of high quality Aspire client integrations, making it easy to pick from many different technologies when building Aspire apps. We expect to continue to add more client integrations, and we welcome contributions of others, but we explicitly don't want to include every possible client integration. The set will be gently curated: in order to make sure that client integrations are useful and dependable, we have some broad criteria below for client integrations contributed to microsoft/aspire. These will likely evolve over time based on feedback, but we expect some requirements (such as actively supported) to remain firm: 1. We expect to welcome any client integrations that would have value to Aspire users and align with what Aspire is intended to do, subject to the below. 2. We don't expect to choose preferred techs. For example, if there are two commonly used providers for database XYZ, we are comfortable with having one client integration for each. We would like client integration naming and granularity to be clear enough that customers can make informed decisions. Aspire is agnostic to your choice of cloud provider, too. 3. We will require that the tech represented by the client integration is being actively supported. In most cases we expect that it is widely used, although we expect that part will be a judgement call. -4. Client integrations contributed to dotnet/aspire must meet the same quality and completeness bar of other contributions. ie., we won't have a lower quality bar for experimental or niche client integrations. +4. Client integrations contributed to microsoft/aspire must meet the same quality and completeness bar of other contributions. ie., we won't have a lower quality bar for experimental or niche client integrations. 5. Where there's a client integration that meets the above criteria, but that isn't something we expect to be a high priority for the Aspire committers to maintain, we'll ask for a plan to sustain it (eg., motivated contributors ready to fix bugs in it) -Note: only client integrations that are built from dotnet/aspire will be able to use the Aspire package name prefix. There is no technical barrier to using client integrations built elsewhere, without the Aspire prefix, but currently our idea is that all broadly available Aspire client integrations will live here in dotnet/aspire and have the Aspire package prefix. We welcome feedback on this and all the other principles listed here, though. +Note: only client integrations that are built from microsoft/aspire will be able to use the Aspire package name prefix. There is no technical barrier to using client integrations built elsewhere, without the Aspire prefix, but currently our idea is that all broadly available Aspire client integrations will live here in microsoft/aspire and have the Aspire package prefix. We welcome feedback on this and all the other principles listed here, though. In summary we encourage and are excited to accept contributions of client integrations, but it's probably a good idea to first open an issue to discuss any new potential client integration before offering a PR, to make sure we're all in agreement that it's a good fit with these principles. diff --git a/tests/Aspire.Azure.AI.OpenAI.Tests/AspireAzureAIOpenAIExtensionsTests.cs b/tests/Aspire.Azure.AI.OpenAI.Tests/AspireAzureAIOpenAIExtensionsTests.cs index 51230527336..bbd194b0553 100644 --- a/tests/Aspire.Azure.AI.OpenAI.Tests/AspireAzureAIOpenAIExtensionsTests.cs +++ b/tests/Aspire.Azure.AI.OpenAI.Tests/AspireAzureAIOpenAIExtensionsTests.cs @@ -141,7 +141,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService("openai2"); var client3 = host.Services.GetRequiredKeyedService("openai3"); diff --git a/tests/Aspire.Azure.Data.Tables.Tests/AspireTablesExtensionsTests.cs b/tests/Aspire.Azure.Data.Tables.Tests/AspireTablesExtensionsTests.cs index 5c0f265ac61..af3b39280b4 100644 --- a/tests/Aspire.Azure.Data.Tables.Tests/AspireTablesExtensionsTests.cs +++ b/tests/Aspire.Azure.Data.Tables.Tests/AspireTablesExtensionsTests.cs @@ -141,7 +141,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService("tables2"); var client3 = host.Services.GetRequiredKeyedService("tables3"); diff --git a/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs b/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs index 48da750f107..7c07bf24f06 100644 --- a/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs +++ b/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs @@ -566,7 +566,7 @@ public void CanAddMultipleKeyedServices(int clientIndex) using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = RetrieveClient(key: null, clientIndex, host); var client2 = RetrieveClient(key: "eh2", clientIndex, host); var client3 = RetrieveClient(key: "eh3", clientIndex, host); diff --git a/tests/Aspire.Azure.Messaging.ServiceBus.Tests/AspireServiceBusExtensionsTests.cs b/tests/Aspire.Azure.Messaging.ServiceBus.Tests/AspireServiceBusExtensionsTests.cs index d63a036e45d..f6a11b825d2 100644 --- a/tests/Aspire.Azure.Messaging.ServiceBus.Tests/AspireServiceBusExtensionsTests.cs +++ b/tests/Aspire.Azure.Messaging.ServiceBus.Tests/AspireServiceBusExtensionsTests.cs @@ -141,7 +141,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService("sb2"); var client3 = host.Services.GetRequiredKeyedService("sb3"); diff --git a/tests/Aspire.Azure.Search.Documents.Tests/AspireAzureSearchExtensionsTests.cs b/tests/Aspire.Azure.Search.Documents.Tests/AspireAzureSearchExtensionsTests.cs index e16790cc279..658afc4a6a2 100644 --- a/tests/Aspire.Azure.Search.Documents.Tests/AspireAzureSearchExtensionsTests.cs +++ b/tests/Aspire.Azure.Search.Documents.Tests/AspireAzureSearchExtensionsTests.cs @@ -85,7 +85,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService("search2"); var client3 = host.Services.GetRequiredKeyedService("search3"); diff --git a/tests/Aspire.Azure.Security.KeyVault.Tests/AspireKeyVaultExtensionsTests.cs b/tests/Aspire.Azure.Security.KeyVault.Tests/AspireKeyVaultExtensionsTests.cs index 682386d3fc9..e9f49b54a78 100644 --- a/tests/Aspire.Azure.Security.KeyVault.Tests/AspireKeyVaultExtensionsTests.cs +++ b/tests/Aspire.Azure.Security.KeyVault.Tests/AspireKeyVaultExtensionsTests.cs @@ -190,7 +190,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService("secrets2"); var client3 = host.Services.GetRequiredKeyedService("secrets3"); diff --git a/tests/Aspire.Azure.Storage.Blobs.Tests/AspireBlobStorageExtensionsTests.cs b/tests/Aspire.Azure.Storage.Blobs.Tests/AspireBlobStorageExtensionsTests.cs index 34bfe089c15..5faa751eb10 100644 --- a/tests/Aspire.Azure.Storage.Blobs.Tests/AspireBlobStorageExtensionsTests.cs +++ b/tests/Aspire.Azure.Storage.Blobs.Tests/AspireBlobStorageExtensionsTests.cs @@ -141,7 +141,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService("blob2"); var client3 = host.Services.GetRequiredKeyedService("blob3"); diff --git a/tests/Aspire.Azure.Storage.Files.DataLake.Tests/AspireDataLakeExtensionsTests.cs b/tests/Aspire.Azure.Storage.Files.DataLake.Tests/AspireDataLakeExtensionsTests.cs index 67734060602..810152e1c6d 100644 --- a/tests/Aspire.Azure.Storage.Files.DataLake.Tests/AspireDataLakeExtensionsTests.cs +++ b/tests/Aspire.Azure.Storage.Files.DataLake.Tests/AspireDataLakeExtensionsTests.cs @@ -152,7 +152,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService($"{ConnectionName}2"); var client3 = host.Services.GetRequiredKeyedService($"{ConnectionName}3"); diff --git a/tests/Aspire.Azure.Storage.Queues.Tests/AspireQueueStorageExtensionsTests.cs b/tests/Aspire.Azure.Storage.Queues.Tests/AspireQueueStorageExtensionsTests.cs index c9c373d7cd2..a03de3837a4 100644 --- a/tests/Aspire.Azure.Storage.Queues.Tests/AspireQueueStorageExtensionsTests.cs +++ b/tests/Aspire.Azure.Storage.Queues.Tests/AspireQueueStorageExtensionsTests.cs @@ -141,7 +141,7 @@ public void CanAddMultipleKeyedServices() using var host = builder.Build(); - // Unkeyed services don't work with keyed services. See https://github.com/dotnet/aspire/issues/3890 + // Unkeyed services don't work with keyed services. See https://github.com/microsoft/aspire/issues/3890 //var client1 = host.Services.GetRequiredService(); var client2 = host.Services.GetRequiredKeyedService("queue2"); var client3 = host.Services.GetRequiredKeyedService("queue3"); diff --git a/tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs index 43fbdfb4c34..da84aac5d5b 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs @@ -88,7 +88,7 @@ await auto.WaitUntilAsync( } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/14307")] + [ActiveIssue("https://github.com/microsoft/aspire/issues/14307")] public async Task Banner_NotDisplayedWithNoLogoFlag() { var repoRoot = CliE2ETestHelpers.GetRepoRoot(); diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs index d4a4ad86fa6..de3bf127406 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs @@ -128,7 +128,7 @@ internal static async Task InstallAspireCliFromPullRequestAsync( int prNumber, SequenceCounter counter) { - var command = $"curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; + var command = $"curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; await auto.TypeAsync(command); await auto.EnterAsync(); await auto.WaitForSuccessPromptFailFastAsync(counter, TimeSpan.FromSeconds(300)); @@ -176,7 +176,7 @@ internal static async Task InstallAspireBundleFromPullRequestAsync( int prNumber, SequenceCounter counter) { - var command = $"ref=$(gh api repos/dotnet/aspire/pulls/{prNumber} --jq '.head.sha') && curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/$ref/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; + var command = $"ref=$(gh api repos/microsoft/aspire/pulls/{prNumber} --jq '.head.sha') && curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/$ref/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; await auto.TypeAsync(command); await auto.EnterAsync(); await auto.WaitForSuccessPromptFailFastAsync(counter, TimeSpan.FromSeconds(300)); @@ -228,7 +228,7 @@ internal static async Task InstallAspireCliVersionAsync( string version, SequenceCounter counter) { - var command = $"curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli.sh | bash -s -- --version \"{version}\""; + var command = $"curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli.sh | bash -s -- --version \"{version}\""; await auto.TypeAsync(command); await auto.EnterAsync(); await auto.WaitForSuccessPromptFailFastAsync(counter, timeout: TimeSpan.FromSeconds(300)); diff --git a/tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs index 2acf4cd94c0..dbb94119a2f 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs @@ -38,7 +38,7 @@ public async Task CreateAndRunJsReactProject() await auto.TypeAsync("aspire run"); await auto.EnterAsync(); - // Regression test for https://github.com/dotnet/aspire/issues/13971 + // Regression test for https://github.com/microsoft/aspire/issues/13971 await auto.WaitUntilAsync(s => { if (s.ContainsText("Select an apphost to use:")) diff --git a/tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs index 00c3ba4a861..719b8fbf0fa 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs @@ -104,7 +104,7 @@ public async Task AgentInit_InstallsPlaywrightCli_AndGeneratesSkillFiles() /// workspace root, playwright-cli install --skills generates skill files in the /// workspace root, not the current working directory. /// - /// This is a regression test for https://github.com/dotnet/aspire/issues/15140 where + /// This is a regression test for https://github.com/microsoft/aspire/issues/15140 where /// the missing WorkingDirectory on ProcessStartInfo caused skill files /// to be dropped in the CLI process's current working directory. ///
diff --git a/tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs index 27d16b0d9c6..cf804095cd0 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Aspire.Cli.EndToEnd.Tests.Helpers; @@ -43,7 +43,7 @@ public async Task CreateAndRunAspireStarterProject() await auto.TypeAsync("aspire run"); await auto.EnterAsync(); - // Regression test for https://github.com/dotnet/aspire/issues/13971 + // Regression test for https://github.com/microsoft/aspire/issues/13971 // If the apphost selection prompt appears, it means multiple apphosts were // incorrectly detected (e.g., AppHost.cs was incorrectly treated as a single-file apphost) await auto.WaitUntilAsync(s => diff --git a/tests/Aspire.Cli.EndToEnd.Tests/StopNonInteractiveTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/StopNonInteractiveTests.cs index e3fda37ec3c..4e8b25ee57d 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/StopNonInteractiveTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/StopNonInteractiveTests.cs @@ -11,7 +11,7 @@ namespace Aspire.Cli.EndToEnd.Tests; /// /// End-to-end tests for aspire stop in non-interactive mode. -/// Validates fix for https://github.com/dotnet/aspire/issues/14558. +/// Validates fix for https://github.com/microsoft/aspire/issues/14558. /// public sealed class StopNonInteractiveTests(ITestOutputHelper output) { diff --git a/tests/Aspire.Cli.EndToEnd.Tests/WaitCommandTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/WaitCommandTests.cs index 51cc7046e66..5b0ad9be9be 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/WaitCommandTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/WaitCommandTests.cs @@ -17,7 +17,7 @@ namespace Aspire.Cli.EndToEnd.Tests; public sealed class WaitCommandTests(ITestOutputHelper output) { [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/14993")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/14993")] public async Task CreateStartWaitAndStopAspireProject() { var repoRoot = CliE2ETestHelpers.GetRepoRoot(); diff --git a/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs b/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs index 3f8c063a81f..a8399bdf029 100644 --- a/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs +++ b/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs @@ -346,7 +346,7 @@ public void VerifyProvenanceFields_WithWorkflowRefValidationFailure_ReturnsWorkf [Theory] [InlineData("https://github.com/microsoft/playwright-cli", "microsoft", "playwright-cli")] - [InlineData("https://github.com/dotnet/aspire", "dotnet", "aspire")] + [InlineData("https://github.com/microsoft/aspire", "microsoft", "aspire")] [InlineData("https://github.com/owner/repo", "owner", "repo")] public void TryParseGitHubOwnerRepo_WithValidUrl_ReturnsTrueAndParsesComponents(string url, string expectedOwner, string expectedRepo) { diff --git a/tests/Aspire.Cli.Tests/Commands/DeployCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/DeployCommandTests.cs index e66a482716d..2a1123a1646 100644 --- a/tests/Aspire.Cli.Tests/Commands/DeployCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/DeployCommandTests.cs @@ -269,7 +269,7 @@ public async Task DeployCommandSucceedsEndToEnd() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/11217")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/11217")] public async Task DeployCommandIncludesDeployFlagInArguments() { using var tempRepo = TemporaryWorkspace.Create(outputHelper); diff --git a/tests/Aspire.Cli.Tests/Commands/ExtensionInternalCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/ExtensionInternalCommandTests.cs index 8a3377c50c1..0a87123e440 100644 --- a/tests/Aspire.Cli.Tests/Commands/ExtensionInternalCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/ExtensionInternalCommandTests.cs @@ -55,7 +55,7 @@ public async Task ExtensionInternalCommand_WithNoSubcommand_ReturnsZero() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/12304")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/12304")] public async Task GetAppHostsCommand_WithSingleProject_ReturnsSuccessWithValidJson() { using var workspace = TemporaryWorkspace.Create(outputHelper); @@ -97,7 +97,7 @@ public async Task GetAppHostsCommand_WithSingleProject_ReturnsSuccessWithValidJs } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/12300")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/12300")] public async Task GetAppHostsCommand_WithMultipleProjects_ReturnsSuccessWithAllCandidates() { using var workspace = TemporaryWorkspace.Create(outputHelper); diff --git a/tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs index 162b2423a8a..64536cec306 100644 --- a/tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs @@ -483,7 +483,7 @@ public async Task AppHostHelper_BuildAppHostAsync_IncludesRelativePathInStatusMe } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/14321")] + [ActiveIssue("https://github.com/microsoft/aspire/issues/14321")] public async Task RunCommand_SkipsBuild_WhenExtensionDevKitCapabilityIsAvailable() { var buildCalled = false; diff --git a/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs b/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs index ee2829bbb78..846c2ada0be 100644 --- a/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs +++ b/tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs @@ -777,7 +777,7 @@ public void SelectionPrompt_ConverterPreservesIntentionalMarkup() { // Arrange - verifies that PromptForSelectionAsync does NOT escape the formatter output, // allowing callers to include intentional Spectre markup (e.g., [bold]...[/]). - // This is a regression test for https://github.com/dotnet/aspire/pull/14422 where + // This is a regression test for https://github.com/microsoft/aspire/pull/14422 where // blanket EscapeMarkup() in the converter broke [bold] rendering in 'aspire add'. var output = new StringBuilder(); var console = AnsiConsole.Create(new AnsiConsoleSettings @@ -846,7 +846,7 @@ public void MakeSafeFormatter_WithBracketsInData_ProducesSafeOutput() // highlighting feature in Spectre manipulates the markup string directly, // which breaks escaped bracket sequences like [[Prod]]. MakeSafeFormatter // strips markup and re-escapes to ensure the text is always safe. - // Regression test for https://github.com/dotnet/aspire/issues/13955 + // Regression test for https://github.com/microsoft/aspire/issues/13955 var output = new StringBuilder(); var console = AnsiConsole.Create(new AnsiConsoleSettings { diff --git a/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs b/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs index 126a71857e3..9003a67c8f4 100644 --- a/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs @@ -835,7 +835,7 @@ public async Task UseOrFindAppHostProjectFileAcceptsDirectoryPathWithRecursiveSe } /// - /// Regression test for https://github.com/dotnet/aspire/issues/13971 + /// Regression test for https://github.com/microsoft/aspire/issues/13971 /// Verifies that AppHost.cs (without SDK directive, with sibling .csproj) is NOT detected as a single-file apphost. /// This simulates the .NET starter template structure. /// @@ -879,7 +879,7 @@ await File.WriteAllTextAsync(appHostCsFile.FullName, """ } /// - /// Regression test for https://github.com/dotnet/aspire/issues/13971 + /// Regression test for https://github.com/microsoft/aspire/issues/13971 /// Verifies that even if apphost.cs has the SDK directive, it is NOT detected if there's a sibling .csproj. /// [Fact] diff --git a/tests/Aspire.Cli.Tests/Projects/ProjectUpdaterTests.cs b/tests/Aspire.Cli.Tests/Projects/ProjectUpdaterTests.cs index 3de33a15f39..4aef9e1b59e 100644 --- a/tests/Aspire.Cli.Tests/Projects/ProjectUpdaterTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/ProjectUpdaterTests.cs @@ -2554,7 +2554,7 @@ public async Task UpdateSdkVersionInCsprojAppHostAsync_RemovesPackageVersionFrom // Directory.Packages.props (as PackageVersion). After SDK migration, the // PackageReference is removed from csproj but the orphaned PackageVersion // must also be removed to avoid NU1009. - // See: https://github.com/dotnet/aspire/issues/14550 + // See: https://github.com/microsoft/aspire/issues/14550 using var workspace = TemporaryWorkspace.Create(outputHelper); var projectFile = Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.csproj"); var originalContent = """ diff --git a/tests/Aspire.Components.Common.TestUtilities/Aspire.Components.Common.TestUtilities.csproj b/tests/Aspire.Components.Common.TestUtilities/Aspire.Components.Common.TestUtilities.csproj index b6311fcee0b..7dd701b3179 100644 --- a/tests/Aspire.Components.Common.TestUtilities/Aspire.Components.Common.TestUtilities.csproj +++ b/tests/Aspire.Components.Common.TestUtilities/Aspire.Components.Common.TestUtilities.csproj @@ -4,7 +4,7 @@ $(DefaultTargetFramework) true false diff --git a/tests/Aspire.Components.Common.TestUtilities/ConformanceTests.cs b/tests/Aspire.Components.Common.TestUtilities/ConformanceTests.cs index 70bed741d5a..58e19088214 100644 --- a/tests/Aspire.Components.Common.TestUtilities/ConformanceTests.cs +++ b/tests/Aspire.Components.Common.TestUtilities/ConformanceTests.cs @@ -128,7 +128,7 @@ public void OptionsTypeIsSealed() [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void HealthChecksRegistersHealthCheckService(bool enabled) { SkipIfHealthChecksAreNotSupported(); @@ -168,7 +168,7 @@ await healthCheckService.CheckHealthAsync(healthCheckRegistration => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void TracingRegistersTraceProvider(bool enabled) { SkipIfTracingIsNotSupported(); @@ -184,7 +184,7 @@ public void TracingRegistersTraceProvider(bool enabled) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void MetricsRegistersMeterProvider(bool enabled) { SkipIfMetricsAreNotSupported(); @@ -199,7 +199,7 @@ public void MetricsRegistersMeterProvider(bool enabled) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void ServiceLifetimeIsAsExpected(bool useKey) { SkipIfRequiredServerConnectionCanNotBeEstablished(); @@ -289,7 +289,7 @@ public void WhenKeyedRegistrationIsUsedThenItsImpossibleToResolveWithoutKey() [InlineData(true, false)] [InlineData(false, true)] [InlineData(false, false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void LoggerFactoryIsUsedByRegisteredClient(bool registerAfterLoggerFactory, bool useKey) { SkipIfRequiredServerConnectionCanNotBeEstablished(); @@ -366,7 +366,7 @@ public void LoggerFactoryIsUsedByRegisteredClient(bool registerAfterLoggerFactor [Theory] [InlineData(null)] [InlineData("key")] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public virtual async Task HealthCheckReportsExpectedStatus(string? key) { SkipIfHealthChecksAreNotSupported(); @@ -419,7 +419,7 @@ public void ConfigurationSchemaInvalidJsonConfigTest() [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void ConnectionInformationIsDelayValidated(bool useKey) { SkipIfComponentIsBuiltBeforeHost(); diff --git a/tests/Aspire.Confluent.Kafka.Tests/OtelMetricsTests.cs b/tests/Aspire.Confluent.Kafka.Tests/OtelMetricsTests.cs index 7efe6ec37bd..5196d6eeb98 100644 --- a/tests/Aspire.Confluent.Kafka.Tests/OtelMetricsTests.cs +++ b/tests/Aspire.Confluent.Kafka.Tests/OtelMetricsTests.cs @@ -27,7 +27,7 @@ public OtelMetricsTests(KafkaContainerFixture? kafkaContainerFixture, ITestOutpu [RequiresFeature(TestFeature.Docker)] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task EnsureMetricsAreProducedAsync(bool useKeyed) { List metrics = new(); diff --git a/tests/Aspire.Confluent.Kafka.Tests/OtelTracesTests.cs b/tests/Aspire.Confluent.Kafka.Tests/OtelTracesTests.cs index 3cfdfbcea5c..1dbe1831dca 100644 --- a/tests/Aspire.Confluent.Kafka.Tests/OtelTracesTests.cs +++ b/tests/Aspire.Confluent.Kafka.Tests/OtelTracesTests.cs @@ -29,7 +29,7 @@ public OtelTracesTests(KafkaContainerFixture? kafkaContainerFixture, ITestOutput [RequiresFeature(TestFeature.Docker)] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task EnsureTracesAreProducedAsync(bool useKeyed) { List activities = new(); diff --git a/tests/Aspire.Dashboard.Tests/CircularBufferTests.cs b/tests/Aspire.Dashboard.Tests/CircularBufferTests.cs index c66fbb6b422..e35116632f5 100644 --- a/tests/Aspire.Dashboard.Tests/CircularBufferTests.cs +++ b/tests/Aspire.Dashboard.Tests/CircularBufferTests.cs @@ -12,7 +12,7 @@ public class CircularBufferTests [Fact] public void LargeData_AddWhenFull_KeepOrder() { - // The data here was reproduced from this issue: https://github.com/dotnet/aspire/issues/7854 + // The data here was reproduced from this issue: https://github.com/microsoft/aspire/issues/7854 var values = new long[10_000]; for (var i = 0; i < values.Length; i++) { diff --git a/tests/Aspire.Deployment.EndToEnd.Tests/AcaDeploymentErrorOutputTests.cs b/tests/Aspire.Deployment.EndToEnd.Tests/AcaDeploymentErrorOutputTests.cs index 36034f0d28b..e93631aefcb 100644 --- a/tests/Aspire.Deployment.EndToEnd.Tests/AcaDeploymentErrorOutputTests.cs +++ b/tests/Aspire.Deployment.EndToEnd.Tests/AcaDeploymentErrorOutputTests.cs @@ -14,7 +14,7 @@ namespace Aspire.Deployment.EndToEnd.Tests; /// that the error output does not contain verbose HTTP details from RequestFailedException. /// /// -/// See https://github.com/dotnet/aspire/issues/12303 +/// See https://github.com/microsoft/aspire/issues/12303 /// public sealed class AcaDeploymentErrorOutputTests(ITestOutputHelper output) { diff --git a/tests/Aspire.Deployment.EndToEnd.Tests/Helpers/DeploymentE2EAutomatorHelpers.cs b/tests/Aspire.Deployment.EndToEnd.Tests/Helpers/DeploymentE2EAutomatorHelpers.cs index a06a0f8d317..85fa9c741f4 100644 --- a/tests/Aspire.Deployment.EndToEnd.Tests/Helpers/DeploymentE2EAutomatorHelpers.cs +++ b/tests/Aspire.Deployment.EndToEnd.Tests/Helpers/DeploymentE2EAutomatorHelpers.cs @@ -49,7 +49,7 @@ internal static async Task InstallAspireCliFromPullRequestAsync( int prNumber, SequenceCounter counter) { - var command = $"curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; + var command = $"curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; await auto.TypeAsync(command); await auto.EnterAsync(); @@ -91,8 +91,8 @@ internal static async Task InstallAspireBundleFromPullRequestAsync( int prNumber, SequenceCounter counter) { - var command = $"ref=$(gh api repos/dotnet/aspire/pulls/{prNumber} --jq '.head.sha') && " + - $"curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/$ref/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; + var command = $"ref=$(gh api repos/microsoft/aspire/pulls/{prNumber} --jq '.head.sha') && " + + $"curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/$ref/eng/scripts/get-aspire-cli-pr.sh | bash -s -- {prNumber}"; await auto.TypeAsync(command); await auto.EnterAsync(); diff --git a/tests/Aspire.EndToEnd.Tests/README.md b/tests/Aspire.EndToEnd.Tests/README.md index 68da5d54ee3..a74613d25b6 100644 --- a/tests/Aspire.EndToEnd.Tests/README.md +++ b/tests/Aspire.EndToEnd.Tests/README.md @@ -36,7 +36,7 @@ The following changes need to be made to when adding a new integration: * If the integration's container starts in a reasonable time, the new test can just be a new `[InlineData]` entry to the existing `VerifyComponentWorks` test. * If the container takes a long time to start, or is flaky, add a separate test scenario (similar to Oracle and CosmosDb). -See https://github.com/dotnet/aspire/pull/4179 for an example. +See https://github.com/microsoft/aspire/pull/4179 for an example. ## (details) What is the goal here? diff --git a/tests/Aspire.Hosting.Azure.Kusto.Tests/KustoFunctionalTests.cs b/tests/Aspire.Hosting.Azure.Kusto.Tests/KustoFunctionalTests.cs index 814bb7c4814..76396f5909b 100644 --- a/tests/Aspire.Hosting.Azure.Kusto.Tests/KustoFunctionalTests.cs +++ b/tests/Aspire.Hosting.Azure.Kusto.Tests/KustoFunctionalTests.cs @@ -40,7 +40,7 @@ public KustoFunctionalTests(ITestOutputHelper testOutputHelper) [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task KustoEmulator_Starts() { using var timeout = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan); @@ -90,7 +90,7 @@ public async Task KustoEmulator_Starts() [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task KustoEmulator_WithDatabase_CanReadIngestedData() { using var timeout = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan); @@ -168,7 +168,7 @@ static async Task> ReadDataAsync(ICslQueryProvider client, Cancel [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task KustoEmulator_WithDatabaseThatAlreadyExists_ErrorIsIgnored() { using var timeout = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan); @@ -195,7 +195,7 @@ public async Task KustoEmulator_WithDatabaseThatAlreadyExists_ErrorIsIgnored() [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task KustoEmulator_WithInvalidDatabase_LogsErrorAndContinues() { using var timeout = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan); @@ -226,7 +226,7 @@ public async Task KustoEmulator_WithInvalidDatabase_LogsErrorAndContinues() [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task KustoEmulator_WithBindMount_IsUsedForPersistence() { using var timeout = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureAppServiceTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureAppServiceTests.cs index 3c50a85bccc..33c896ed5d4 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureAppServiceTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureAppServiceTests.cs @@ -379,7 +379,7 @@ public void AzureAppServiceEnvironmentImplementsIAzureComputeEnvironmentResource } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task PublishAsAzureAppServiceWebsite_ThrowsIfNoEnvironment() { static async Task RunTest(Action action) @@ -411,7 +411,7 @@ await RunTest(builder => } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task MultipleAzureAppServiceEnvironmentsSupported() { using var tempDir = new TestTempDirectory(); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs index 940fcb84e18..9471974844e 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs @@ -250,7 +250,7 @@ public async Task BicepResourceHasPipelineStepAnnotationWithCorrectConfiguration [Fact] public void GetBicepTemplateFile_WithTemplateFile_ReturnsOriginalPathWhenDirectoryProvided() { - // This test verifies the fix for https://github.com/dotnet/aspire/issues/13967 + // This test verifies the fix for https://github.com/microsoft/aspire/issues/13967 // When a templateFile is specified, GetBicepTemplateFile should return the original path // and not combine it with the directory parameter. diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs index acd4e01168d..246590dd3d1 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs @@ -1399,7 +1399,7 @@ public async Task CompactNamingMultipleVolumesHaveUniqueNames() await Verify(manifest.BicepText, "bicep"); } - // see https://github.com/dotnet/aspire/issues/8381 for more information on this scenario + // see https://github.com/microsoft/aspire/issues/8381 for more information on this scenario // Azure SqlServer needs an admin when it is first provisioned. To supply this, we use the // principalId from the Azure Container App Environment. [Fact] diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBEmulatorFunctionalTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBEmulatorFunctionalTests.cs index 48fba780294..567a8ae5564 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBEmulatorFunctionalTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBEmulatorFunctionalTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Net; @@ -18,10 +18,10 @@ namespace Aspire.Hosting.Azure.Tests; public class AzureCosmosDBEmulatorFunctionalTests(ITestOutputHelper testOutputHelper) { [Theory] - // [InlineData(true)] // "Using CosmosDB emulator in integration tests leads to flaky tests - https://github.com/dotnet/aspire/issues/5820" + // [InlineData(true)] // "Using CosmosDB emulator in integration tests leads to flaky tests - https://github.com/microsoft/aspire/issues/5820" [InlineData(false)] [RequiresFeature(TestFeature.Docker)] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/14099")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/14099")] public async Task VerifyWaitForOnCosmosDBEmulatorBlocksDependentResources(bool usePreview) { // Cosmos can be pretty slow to spin up, lets give it plenty of time. @@ -60,7 +60,7 @@ public async Task VerifyWaitForOnCosmosDBEmulatorBlocksDependentResources(bool u await app.StopAsync(); } - [Theory(Skip = "Using CosmosDB emulator in integration tests leads to flaky tests - https://github.com/dotnet/aspire/issues/5820")] + [Theory(Skip = "Using CosmosDB emulator in integration tests leads to flaky tests - https://github.com/microsoft/aspire/issues/5820")] [InlineData(true)] [InlineData(false)] [RequiresFeature(TestFeature.Docker)] @@ -130,7 +130,7 @@ await pipeline.ExecuteAsync(async token => }, cts.Token); } - [Theory(Skip = "Using CosmosDB emulator in integration tests leads to flaky tests - https://github.com/dotnet/aspire/issues/5820")] + [Theory(Skip = "Using CosmosDB emulator in integration tests leads to flaky tests - https://github.com/microsoft/aspire/issues/5820")] [InlineData(true)] [InlineData(false)] [RequiresFeature(TestFeature.Docker)] @@ -269,7 +269,7 @@ await pipeline.ExecuteAsync(async token => [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/7178")] + [ActiveIssue("https://github.com/microsoft/aspire/issues/7178")] public async Task AddAzureCosmosDB_RunAsEmulator_CreatesDatabase() { var cts = new CancellationTokenSource(TimeSpan.FromMinutes(10)); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs index 3de799e807f..b5928f180d4 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs @@ -438,7 +438,7 @@ public async Task DeployAsync_WithProjectResource_Works() [Theory] [InlineData("deploy")] [InlineData("diagnostics")] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/13287")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/13287")] public async Task DeployAsync_WithMultipleComputeEnvironments_Works(string step) { // Arrange diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureEnvironmentResourceTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureEnvironmentResourceTests.cs index 4f764ed1cf2..814ef1db188 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureEnvironmentResourceTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureEnvironmentResourceTests.cs @@ -250,7 +250,7 @@ public void AzurePublishingContext_WithBicepTemplateFile_WorksWithRelativePath() static async Task RunTest(string tempDir) { - // This test verifies the fix for https://github.com/dotnet/aspire/issues/13967 + // This test verifies the fix for https://github.com/microsoft/aspire/issues/13967 // When using AzureBicepResource with a relative templateFile and AzurePublishingContext, // the bicep file should be correctly copied to the output directory. diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureServiceBusExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureServiceBusExtensionsTests.cs index f62a9d4919b..20320a5eb5d 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureServiceBusExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureServiceBusExtensionsTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json.Nodes; @@ -67,7 +67,7 @@ public async Task TopicNamesCanBeLongerThan24(bool useObsoleteMethods) } - [Fact(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/dotnet/aspire/issues/7066")] + [Fact(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/microsoft/aspire/issues/7066")] [RequiresFeature(TestFeature.Docker)] public async Task VerifyWaitForOnServiceBusEmulatorBlocksDependentResources() { @@ -108,7 +108,7 @@ public async Task VerifyWaitForOnServiceBusEmulatorBlocksDependentResources() await app.StopAsync(); } - [Theory(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/dotnet/aspire/issues/7066")] + [Theory(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/microsoft/aspire/issues/7066")] [InlineData(null)] [InlineData("other")] [RequiresFeature(TestFeature.Docker)] @@ -768,7 +768,7 @@ param principalId string Assert.Equal(expectedBicep, sbRolesManifest.BicepText); } - [Fact(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/dotnet/aspire/issues/7066")] + [Fact(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/microsoft/aspire/issues/7066")] [RequiresFeature(TestFeature.Docker)] public async Task AzureServiceBusEmulator_WithCustomConfig() { diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_AutoCreatesBothSubnetAndStorage.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_AutoCreatesBothSubnetAndStorage.verified.bicep index e75bbbbd588..46c3424bddc 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_AutoCreatesBothSubnetAndStorage.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_AutoCreatesBothSubnetAndStorage.verified.bicep @@ -1,4 +1,4 @@ -// Resource: api-identity +// Resource: api-identity @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location @@ -103,7 +103,7 @@ resource script_sql_db 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' storageAccountSettings: { storageAccountName: sql_store_outputs_name } diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_BothExplicitSubnetAndStorage.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_BothExplicitSubnetAndStorage.verified.bicep index e3d1e16e20b..24377ddb064 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_BothExplicitSubnetAndStorage.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_BothExplicitSubnetAndStorage.verified.bicep @@ -1,4 +1,4 @@ -// Resource: api-identity +// Resource: api-identity @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location @@ -103,7 +103,7 @@ resource script_sql_db 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' storageAccountSettings: { storageAccountName: depscriptstorage_outputs_name } diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitStorage_AutoCreatesSubnet.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitStorage_AutoCreatesSubnet.verified.bicep index 6cad2dbdba5..13d1fc52ad2 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitStorage_AutoCreatesSubnet.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitStorage_AutoCreatesSubnet.verified.bicep @@ -1,4 +1,4 @@ -// Resource: api-identity +// Resource: api-identity @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location @@ -103,7 +103,7 @@ resource script_sql_db 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' storageAccountSettings: { storageAccountName: depscriptstorage_outputs_name } diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitSubnet_AutoCreatesStorage.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitSubnet_AutoCreatesStorage.verified.bicep index 37026f1fdf2..4b94096a4a3 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitSubnet_AutoCreatesStorage.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_ExplicitSubnet_AutoCreatesStorage.verified.bicep @@ -1,4 +1,4 @@ -// Resource: api-identity +// Resource: api-identity @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location @@ -103,7 +103,7 @@ resource script_sql_db 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' storageAccountSettings: { storageAccountName: sql_store_outputs_name } diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_StorageBeforePrivateEndpoint.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_StorageBeforePrivateEndpoint.verified.bicep index 6cad2dbdba5..13d1fc52ad2 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_StorageBeforePrivateEndpoint.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_StorageBeforePrivateEndpoint.verified.bicep @@ -1,4 +1,4 @@ -// Resource: api-identity +// Resource: api-identity @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location @@ -103,7 +103,7 @@ resource script_sql_db 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' storageAccountSettings: { storageAccountName: depscriptstorage_outputs_name } diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_SubnetBeforePrivateEndpoint.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_SubnetBeforePrivateEndpoint.verified.bicep index 37026f1fdf2..4b94096a4a3 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_SubnetBeforePrivateEndpoint.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSqlDeploymentScriptTests.SqlWithPrivateEndpoint_SubnetBeforePrivateEndpoint.verified.bicep @@ -1,4 +1,4 @@ -// Resource: api-identity +// Resource: api-identity @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location @@ -103,7 +103,7 @@ resource script_sql_db 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' storageAccountSettings: { storageAccountName: sql_store_outputs_name } diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/RoleAssignmentTests.SqlSupport.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/RoleAssignmentTests.SqlSupport.verified.bicep index 1555f03fe38..4235d5be834 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/RoleAssignmentTests.SqlSupport.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/RoleAssignmentTests.SqlSupport.verified.bicep @@ -1,4 +1,4 @@ -@description('The location for the resource(s) to be deployed.') +@description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location param sql_outputs_name string @@ -56,6 +56,6 @@ resource script_sql_db 'Microsoft.Resources/deploymentScripts@2023-08-01' = { value: mi.properties.clientId } ] - scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' + scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\n\$sqlDatabaseName = "\$env:DBNAME"\n\$principalName = "\$env:PRINCIPALNAME"\n\$id = "\$env:ID"\n\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/microsoft/aspire/issues/9926)\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\nImport-Module SqlServer\n\n\$sqlCmd = @"\nDECLARE @name SYSNAME = \'\$principalName\';\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\n\n-- Convert the guid to the right type\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\n\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\nEXEC (@cmd);\n\n-- Assign roles to the new user\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\nEXEC (@role1);\n\n"@\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\n\nWrite-Host \$sqlCmd\n\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\n\n\$maxRetries = 5\n\$retryDelay = 60\n\$attempt = 0\n\$success = \$false\n\nwhile (-not \$success -and \$attempt -lt \$maxRetries) {\n \$attempt++\n Write-Host "Attempt \$attempt of \$maxRetries..."\n try {\n Invoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd\n \$success = \$true\n Write-Host "SQL command succeeded on attempt \$attempt."\n } catch {\n Write-Host "Attempt \$attempt failed: \$_"\n if (\$attempt -lt \$maxRetries) {\n Write-Host "Retrying in \$retryDelay seconds..."\n Start-Sleep -Seconds \$retryDelay\n } else {\n throw\n }\n }\n}' } } \ No newline at end of file diff --git a/tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs b/tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs index 15034bb96c0..d25c36fb2d0 100644 --- a/tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs +++ b/tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs @@ -652,7 +652,7 @@ public async Task PushImageToRegistry_WithLocalRegistry_OnlyTagsImage() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/13878")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/13878")] public async Task PushImageToRegistry_WithRemoteRegistry_PushesImage() { using var tempDir = new TestTempDirectory(); diff --git a/tests/Aspire.Hosting.JavaScript.Tests/NodeFunctionalTests.cs b/tests/Aspire.Hosting.JavaScript.Tests/NodeFunctionalTests.cs index 7ae44fe74c6..21568d16ae1 100644 --- a/tests/Aspire.Hosting.JavaScript.Tests/NodeFunctionalTests.cs +++ b/tests/Aspire.Hosting.JavaScript.Tests/NodeFunctionalTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Aspire.TestUtilities; @@ -18,7 +18,7 @@ public NodeFunctionalTests(NodeAppFixture nodeJsFixture) [Fact] [RequiresTools(["node"])] - [ActiveIssue("https://github.com/dotnet/aspire/issues/4508", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/4508", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task VerifyNodeAppWorks() { using var cts = new CancellationTokenSource(TestConstants.LongTimeoutDuration); @@ -30,7 +30,7 @@ public async Task VerifyNodeAppWorks() [Fact] [RequiresTools(["npm"])] - [ActiveIssue("https://github.com/dotnet/aspire/issues/4508", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/4508", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task VerifyNpmAppWorks() { using var cts = new CancellationTokenSource(TestConstants.LongTimeoutDuration); diff --git a/tests/Aspire.Hosting.Kafka.Tests/KafkaFunctionalTests.cs b/tests/Aspire.Hosting.Kafka.Tests/KafkaFunctionalTests.cs index c3cca890954..0de1d77c8bb 100644 --- a/tests/Aspire.Hosting.Kafka.Tests/KafkaFunctionalTests.cs +++ b/tests/Aspire.Hosting.Kafka.Tests/KafkaFunctionalTests.cs @@ -18,7 +18,7 @@ public class KafkaFunctionalTests(ITestOutputHelper testOutputHelper) { [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task VerifyWaitForOnKafkaBlocksDependentResources() { using var builder = TestDistributedApplicationBuilder.CreateWithTestContainerRegistry(testOutputHelper); @@ -56,7 +56,7 @@ public async Task VerifyWaitForOnKafkaBlocksDependentResources() [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task VerifyKafkaResource() { var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3)); @@ -114,7 +114,7 @@ await pipeline.ExecuteAsync(async token => [InlineData(true)] [InlineData(false)] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task WithDataShouldPersistStateBetweenUsages(bool useVolume) { var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3)); diff --git a/tests/Aspire.Hosting.Kubernetes.Tests/KubernetesEnvironmentResourceTests.cs b/tests/Aspire.Hosting.Kubernetes.Tests/KubernetesEnvironmentResourceTests.cs index 68b23573eca..fc89d7f20c8 100644 --- a/tests/Aspire.Hosting.Kubernetes.Tests/KubernetesEnvironmentResourceTests.cs +++ b/tests/Aspire.Hosting.Kubernetes.Tests/KubernetesEnvironmentResourceTests.cs @@ -38,7 +38,7 @@ await Verify(File.ReadAllText(chartYaml), "yaml") } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task PublishAsKubernetesService_ThrowsIfNoEnvironment() { static async Task RunTest(Action action) @@ -70,7 +70,7 @@ await RunTest(builder => } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11818", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task MultipleKubernetesEnvironmentsSupported() { using var tempDir = new TestTempDirectory(); diff --git a/tests/Aspire.Hosting.OpenAI.Tests/OpenAIFunctionalTests.cs b/tests/Aspire.Hosting.OpenAI.Tests/OpenAIFunctionalTests.cs index 30a00358ec9..143e1a38245 100644 --- a/tests/Aspire.Hosting.OpenAI.Tests/OpenAIFunctionalTests.cs +++ b/tests/Aspire.Hosting.OpenAI.Tests/OpenAIFunctionalTests.cs @@ -14,7 +14,7 @@ public class OpenAIFunctionalTests { [Fact] [RequiresFeature(TestFeature.Docker)] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/10977")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/10977")] public async Task DependentResourceWaitsForOpenAIModelResourceWithHealthCheckToBeHealthy() { using var cts = new CancellationTokenSource(TestConstants.LongTimeoutDuration); diff --git a/tests/Aspire.Hosting.Oracle.Tests/OracleFunctionalTests.cs b/tests/Aspire.Hosting.Oracle.Tests/OracleFunctionalTests.cs index a4f16026e59..5162ce86da8 100644 --- a/tests/Aspire.Hosting.Oracle.Tests/OracleFunctionalTests.cs +++ b/tests/Aspire.Hosting.Oracle.Tests/OracleFunctionalTests.cs @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Oracle.Tests; -[ActiveIssue("https://github.com/dotnet/aspire/issues/5362", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningOnCI))] +[ActiveIssue("https://github.com/microsoft/aspire/issues/5362", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningOnCI))] public class OracleFunctionalTests(ITestOutputHelper testOutputHelper) { // Folders created for mounted folders need to be granted specific permissions @@ -69,7 +69,7 @@ public async Task VerifyEfOracle() [Theory] [InlineData(true)] - [InlineData(false, Skip = "https://github.com/dotnet/aspire/issues/5191")] + [InlineData(false, Skip = "https://github.com/microsoft/aspire/issues/5191")] [RequiresFeature(TestFeature.Docker)] public async Task WithDataShouldPersistStateBetweenUsages(bool useVolume) { @@ -344,7 +344,7 @@ await pipeline.ExecuteAsync(async token => [Theory] [InlineData(true)] - [InlineData(false, Skip = "https://github.com/dotnet/aspire/issues/5190")] + [InlineData(false, Skip = "https://github.com/microsoft/aspire/issues/5190")] [RequiresFeature(TestFeature.Docker)] public async Task VerifyWithInitFiles(bool init) { diff --git a/tests/Aspire.Hosting.Python.Tests/AddPythonAppTests.cs b/tests/Aspire.Hosting.Python.Tests/AddPythonAppTests.cs index 85f81e51b97..5f5cf8f813f 100644 --- a/tests/Aspire.Hosting.Python.Tests/AddPythonAppTests.cs +++ b/tests/Aspire.Hosting.Python.Tests/AddPythonAppTests.cs @@ -98,7 +98,7 @@ public async Task AddInstrumentedPythonProjectProducesDockerfileResourceInManife [Fact] [RequiresTools(["python"])] - [ActiveIssue("https://github.com/dotnet/aspire/issues/8466")] + [ActiveIssue("https://github.com/microsoft/aspire/issues/8466")] public async Task PythonResourceFinishesSuccessfully() { var (projectDirectory, _, scriptName) = CreateTempPythonProject(outputHelper); diff --git a/tests/Aspire.Hosting.Sdk.Tests/NuGetUtils.Tests.cs b/tests/Aspire.Hosting.Sdk.Tests/NuGetUtils.Tests.cs index 46ba5483885..d1faac70ab4 100644 --- a/tests/Aspire.Hosting.Sdk.Tests/NuGetUtils.Tests.cs +++ b/tests/Aspire.Hosting.Sdk.Tests/NuGetUtils.Tests.cs @@ -19,7 +19,7 @@ public class NuGetUtilsTests [InlineData("osx-arm64", "osx-arm64")] //Compatible RID cases - [InlineData("rhel.8-x64", "linux-x64")] // https://github.com/dotnet/aspire/issues/5486 + [InlineData("rhel.8-x64", "linux-x64")] // https://github.com/microsoft/aspire/issues/5486 [InlineData("ubuntu.23.04-x64", "linux-x64")] [InlineData("fedora.39-x64", "linux-x64")] [InlineData("linux-musl-x64", "linux-x64")] diff --git a/tests/Aspire.Hosting.Testing.Tests/TestingFactoryTests.cs b/tests/Aspire.Hosting.Testing.Tests/TestingFactoryTests.cs index 7143eb520bc..efcc544e386 100644 --- a/tests/Aspire.Hosting.Testing.Tests/TestingFactoryTests.cs +++ b/tests/Aspire.Hosting.Testing.Tests/TestingFactoryTests.cs @@ -68,7 +68,7 @@ public void SetsCorrectContentRoot() [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/4650")] + [ActiveIssue("https://github.com/microsoft/aspire/issues/4650")] public async Task SelectsFirstLaunchProfile() { var config = _app.Services.GetRequiredService(); diff --git a/tests/Aspire.Hosting.Tests/Backchannel/Exec/ProjectResourceExecTests.cs b/tests/Aspire.Hosting.Tests/Backchannel/Exec/ProjectResourceExecTests.cs index 99e2396a8fc..2c8d023a356 100644 --- a/tests/Aspire.Hosting.Tests/Backchannel/Exec/ProjectResourceExecTests.cs +++ b/tests/Aspire.Hosting.Tests/Backchannel/Exec/ProjectResourceExecTests.cs @@ -34,7 +34,7 @@ public async Task Exec_NotFoundTargetResource_ShouldProduceLogs() } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11158")] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11158")] public async Task Exec_DotnetBuildFail_ProducesLogs_Fail() { string[] args = [ @@ -78,7 +78,7 @@ public async Task Exec_NonExistingCommand_ProducesLogs_Fail() } [Fact] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11143", TestPlatforms.Windows)] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11143", TestPlatforms.Windows)] public async Task Exec_DotnetInfo_ProducesLogs_Success() { string[] args = [ diff --git a/tests/Aspire.Hosting.Tests/Cli/CliOrphanDetectorTests.cs b/tests/Aspire.Hosting.Tests/Cli/CliOrphanDetectorTests.cs index d0b03ac1973..5bb4ebc6715 100644 --- a/tests/Aspire.Hosting.Tests/Cli/CliOrphanDetectorTests.cs +++ b/tests/Aspire.Hosting.Tests/Cli/CliOrphanDetectorTests.cs @@ -100,7 +100,7 @@ public async Task CliOrphanDetectorFallsBackToPidOnlyWhenStartTimeInvalid() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/12710")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/12710")] public async Task CliOrphanDetectorContinuesRunningWhenProcessAliveWithCorrectStartTime() { var expectedStartTime = DateTime.Now.AddMinutes(-5); @@ -177,7 +177,7 @@ public async Task CliOrphanDetectorStopsWhenProcessHasDifferentStartTime() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/12710")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/12710")] public async Task CliOrphanDetectorAfterTheProcessWasRunningForAWhileThenStops() { var configuration = new ConfigurationBuilder() diff --git a/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs b/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs index 32626064aa0..47de22eb463 100644 --- a/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs +++ b/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs @@ -617,7 +617,7 @@ public Task AfterEndpointsAllocatedAsync(DistributedApplicationModel appModel, C } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/9340")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/9340")] public async Task TestServicesWithMultipleReplicas() { var replicaCount = 3; @@ -1496,7 +1496,7 @@ public async Task ProxylessEndpointWithoutPortThrows() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/8728")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/8728")] public async Task ProxylessEndpointWorks() { const string testName = "proxyless-endpoint-works"; diff --git a/tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs b/tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs index 6b92e61482f..3dd8eeea65d 100644 --- a/tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs +++ b/tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs @@ -697,7 +697,7 @@ public async Task ExecuteAsync_WithDuplicateAnnotationStepNames_ThrowsInvalidOpe } // Test for multiple failing steps at the same level removed due to inherent race conditions. - // See https://github.com/dotnet/aspire/issues/12200 + // See https://github.com/microsoft/aspire/issues/12200 [Fact] public async Task ExecuteAsync_WithFailingStep_PreservesOriginalStackTrace() @@ -2028,7 +2028,7 @@ public async Task FilterStepsForExecution_WithRequiredBy_IncludesTransitiveDepen } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/13083")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/13083")] public async Task ProcessParametersStep_ValidatesBehavior() { // Arrange diff --git a/tests/Aspire.Hosting.Tests/SlimTestProgramTests.cs b/tests/Aspire.Hosting.Tests/SlimTestProgramTests.cs index 8fe4629d7b3..83471ab7172 100644 --- a/tests/Aspire.Hosting.Tests/SlimTestProgramTests.cs +++ b/tests/Aspire.Hosting.Tests/SlimTestProgramTests.cs @@ -19,7 +19,7 @@ public SlimTestProgramTests(SlimTestProgramFixture slimTestProgramFixture) } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/9672")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/9672")] public async Task TestProjectStartsAndStopsCleanly() { var testProgram = _slimTestProgramFixture.TestProgram; @@ -44,7 +44,7 @@ private static async Task EnsureServicesAreRunning(TestProgram testProgram, Canc } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/9671")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/9671")] public async Task TestPortOnEndpointAnnotationAndAllocatedEndpointAnnotationMatch() { var testProgram = _slimTestProgramFixture.TestProgram; @@ -63,7 +63,7 @@ public async Task TestPortOnEndpointAnnotationAndAllocatedEndpointAnnotationMatc } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/9673")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/9673")] public async Task TestPortOnEndpointAnnotationAndAllocatedEndpointAnnotationMatchForReplicatedServices() { var testProgram = _slimTestProgramFixture.TestProgram; diff --git a/tests/Aspire.Hosting.Tests/Utils/TestDistributedApplicationBuilder.cs b/tests/Aspire.Hosting.Tests/Utils/TestDistributedApplicationBuilder.cs index 80359b7b31c..9168c7a43cf 100644 --- a/tests/Aspire.Hosting.Tests/Utils/TestDistributedApplicationBuilder.cs +++ b/tests/Aspire.Hosting.Tests/Utils/TestDistributedApplicationBuilder.cs @@ -55,7 +55,7 @@ private static IDistributedApplicationTestingBuilder CreateCore(string[] args, A // TODO: consider centralizing this to DistributedApplicationFactory by default once consumers have a way to opt-out // E.g., once https://github.com/dotnet/extensions/pull/5801 is released. - // Discussion: https://github.com/dotnet/aspire/pull/7335/files#r1936799460 + // Discussion: https://github.com/microsoft/aspire/pull/7335/files#r1936799460 builder.Services.ConfigureHttpClientDefaults(http => http.AddStandardResilienceHandler()); builder.Services.AddSingleton(sp => new ApplicationOrchestratorProxy(sp.GetRequiredService())); diff --git a/tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs b/tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs index e338e906361..1338dc49b16 100644 --- a/tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs +++ b/tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Net; @@ -206,7 +206,7 @@ public async Task WithHttpCommand_ResultsInExpectedResultForStatusCode(int statu [InlineData("get", true)] [InlineData("post", false)] [Theory] - [ActiveIssue("https://github.com/dotnet/aspire/issues/9725")] + [ActiveIssue("https://github.com/microsoft/aspire/issues/9725")] public async Task WithHttpCommand_ResultsInExpectedResultForHttpMethod(string? httpMethod, bool expectSuccess) { // Arrange @@ -402,7 +402,7 @@ public async Task WithHttpCommand_CallsGetResponseCallback_AfterSendingRequest() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/8101")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/8101")] public async Task WithHttpCommand_EnablesCommandOnceResourceIsRunning() { // Arrange diff --git a/tests/Aspire.Hosting.Valkey.Tests/ValkeyFunctionalTests.cs b/tests/Aspire.Hosting.Valkey.Tests/ValkeyFunctionalTests.cs index c4b9c162770..7c2395adb77 100644 --- a/tests/Aspire.Hosting.Valkey.Tests/ValkeyFunctionalTests.cs +++ b/tests/Aspire.Hosting.Valkey.Tests/ValkeyFunctionalTests.cs @@ -18,7 +18,7 @@ public class ValkeyFunctionalTests(ITestOutputHelper testOutputHelper) { [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task VerifyValkeyResource() { using var builder = TestDistributedApplicationBuilder.CreateWithTestContainerRegistry(testOutputHelper); @@ -60,7 +60,7 @@ public async Task VerifyValkeyResource() [InlineData(true)] [InlineData(false)] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task WithDataShouldPersistStateBetweenUsages(bool useVolume) { string? volumeName = null; @@ -200,7 +200,7 @@ public async Task WithDataShouldPersistStateBetweenUsages(bool useVolume) [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task VerifyWaitForOnValkeyBlocksDependentResources() { var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3)); diff --git a/tests/Aspire.Hosting.Yarp.Tests/YarpFunctionalTests.cs b/tests/Aspire.Hosting.Yarp.Tests/YarpFunctionalTests.cs index 72acb094ca0..92c1b8febb5 100644 --- a/tests/Aspire.Hosting.Yarp.Tests/YarpFunctionalTests.cs +++ b/tests/Aspire.Hosting.Yarp.Tests/YarpFunctionalTests.cs @@ -11,7 +11,7 @@ public class YarpFunctionalTests(ITestOutputHelper testOutputHelper) { [Fact] [RequiresFeature(TestFeature.Docker)] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/9344")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/9344")] public async Task VerifyYarpResourceExtensionsConfig() { await VerifyYarpResource((yarp, endpoint) => diff --git a/tests/Aspire.Playground.Tests/AppHostTests.cs b/tests/Aspire.Playground.Tests/AppHostTests.cs index 418f0bb8087..3166e44ada5 100644 --- a/tests/Aspire.Playground.Tests/AppHostTests.cs +++ b/tests/Aspire.Playground.Tests/AppHostTests.cs @@ -30,7 +30,7 @@ public AppHostTests(ITestOutputHelper testOutput) [Theory] [MemberData(nameof(TestEndpoints))] - [QuarantinedTest("https://github.com/dotnet/aspire/issues/6866")] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/6866")] public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints) { var appHostType = testEndpoints.AppHostType!; @@ -132,7 +132,7 @@ public static IList GetAllTestEndpoints() { IList candidates = [ - // Disable due to https://github.com/dotnet/aspire/issues/5959 + // Disable due to https://github.com/microsoft/aspire/issues/5959 //new TestEndpoints(typeof(Projects.EventHubs.AppHost", // resourceEndpoints: new() { { "api", ["/alive", "/health"] } }, // waitForTexts: [ @@ -163,7 +163,7 @@ public static IList GetAllTestEndpoints() // Cosmos emulator is extremely slow to start up and unreliable in CI //new TestEndpoints(typeof(Projects.CosmosEndToEnd_AppHost), // resourceEndpoints: new() { { "api", ["/alive", "/health", "/"] } }, - // // "/ef" - disabled due to https://github.com/dotnet/aspire/issues/5415 + // // "/ef" - disabled due to https://github.com/microsoft/aspire/issues/5415 // waitForTexts: [ // new ("cosmos", "Started$"), // new ("api", "Application started") diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj index f66ccb9200d..6fa2af71337 100644 --- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj +++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj @@ -27,7 +27,7 @@ xunit.runner.json + diff --git a/tests/Aspire.Pomelo.EntityFrameworkCore.MySql.Tests/AspireEFMySqlExtensionsTests.cs b/tests/Aspire.Pomelo.EntityFrameworkCore.MySql.Tests/AspireEFMySqlExtensionsTests.cs index b39977a45f3..b1e52cdc7e1 100644 --- a/tests/Aspire.Pomelo.EntityFrameworkCore.MySql.Tests/AspireEFMySqlExtensionsTests.cs +++ b/tests/Aspire.Pomelo.EntityFrameworkCore.MySql.Tests/AspireEFMySqlExtensionsTests.cs @@ -177,7 +177,7 @@ public void CanConfigureDbContextOptionsWithoutRetry() [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void CanConfigureCommandTimeout(bool useSettings) { var builder = Host.CreateEmptyApplicationBuilder(null); @@ -213,7 +213,7 @@ public void CanConfigureCommandTimeout(bool useSettings) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void CommandTimeoutFromSettingsWinsOverOthers(bool useSettings) { var builder = Host.CreateEmptyApplicationBuilder(null); @@ -252,7 +252,7 @@ public void CommandTimeoutFromSettingsWinsOverOthers(bool useSettings) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void ThrowsWhenDbContextIsRegisteredBeforeAspireComponent(bool useServiceType) { var builder = Host.CreateEmptyApplicationBuilder(new HostApplicationBuilderSettings { EnvironmentName = Environments.Development }); @@ -276,7 +276,7 @@ public void ThrowsWhenDbContextIsRegisteredBeforeAspireComponent(bool useService [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public void DoesntThrowWhenDbContextIsRegisteredBeforeAspireComponentProduction(bool useServiceType) { var builder = Host.CreateEmptyApplicationBuilder(new HostApplicationBuilderSettings { EnvironmentName = Environments.Production }); diff --git a/tests/Aspire.RabbitMQ.Client.Tests/AspireRabbitMQLoggingTests.cs b/tests/Aspire.RabbitMQ.Client.Tests/AspireRabbitMQLoggingTests.cs index ded79fc6548..15de0df9ceb 100644 --- a/tests/Aspire.RabbitMQ.Client.Tests/AspireRabbitMQLoggingTests.cs +++ b/tests/Aspire.RabbitMQ.Client.Tests/AspireRabbitMQLoggingTests.cs @@ -32,7 +32,7 @@ public class AspireRabbitMQLoggingTests /// [Fact] [RequiresFeature(TestFeature.Docker)] - [ActiveIssue("https://github.com/dotnet/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] + [ActiveIssue("https://github.com/microsoft/aspire/issues/11820", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningFromAzdo))] public async Task EndToEndLoggingTest() { await using var rabbitMqContainer = new RabbitMqBuilder() diff --git a/tests/Aspire.StackExchange.Redis.Tests/AspireRedisExtensionsTests.cs b/tests/Aspire.StackExchange.Redis.Tests/AspireRedisExtensionsTests.cs index 4e8db257b54..a56d3089d2c 100644 --- a/tests/Aspire.StackExchange.Redis.Tests/AspireRedisExtensionsTests.cs +++ b/tests/Aspire.StackExchange.Redis.Tests/AspireRedisExtensionsTests.cs @@ -200,7 +200,7 @@ public void AbortOnConnectFailDefaults(bool useKeyed, IEnumerable /// Verifies that both distributed and output caching components can be added to the same builder and their HealthChecks don't conflict. - /// See https://github.com/dotnet/aspire/issues/705 + /// See https://github.com/microsoft/aspire/issues/705 /// [Theory] [InlineData(true)] diff --git a/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj b/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj index c724a0fb0da..e9a74f4a277 100644 --- a/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj +++ b/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj @@ -30,7 +30,7 @@ 15m + true $(DotNetSdkPreviousVersionForTesting) @@ -141,7 +141,7 @@
- + diff --git a/tools/QuarantineTools/README.md b/tools/QuarantineTools/README.md index 1c151951ed9..c8f0782995d 100644 --- a/tools/QuarantineTools/README.md +++ b/tools/QuarantineTools/README.md @@ -16,10 +16,10 @@ Roslyn based utility to add or remove `[QuarantinedTest]` or `[ActiveIssue]` att dotnet run --project tools/QuarantineTools -- --help # Quarantine a test with QuarantinedTest (default mode) -dotnet run --project tools/QuarantineTools -- -q -i https://github.com/dotnet/aspire/issues/1234 Full.Namespace.Type.Method +dotnet run --project tools/QuarantineTools -- -q -i https://github.com/microsoft/aspire/issues/1234 Full.Namespace.Type.Method # Disable a test with ActiveIssue attribute -dotnet run --project tools/QuarantineTools -- -q -m activeissue -i https://github.com/dotnet/aspire/issues/1234 Full.Namespace.Type.Method +dotnet run --project tools/QuarantineTools -- -q -m activeissue -i https://github.com/microsoft/aspire/issues/1234 Full.Namespace.Type.Method # Unquarantine a test with QuarantinedTest (removes attribute) dotnet run --project tools/QuarantineTools -- -u Full.Namespace.Type.Method diff --git a/tools/ReleaseNotes/data/whats-new-91.md b/tools/ReleaseNotes/data/whats-new-91.md index edd2641deeb..296fefa3d1c 100644 --- a/tools/ReleaseNotes/data/whats-new-91.md +++ b/tools/ReleaseNotes/data/whats-new-91.md @@ -16,7 +16,7 @@ ms.date: 04/15/2025 As always, we focused on highly requested features and pain points from the community. Our theme for 9.1 was "polish, polish, polish"—so you see quality of life fixes throughout the whole platform. Some highlights from this release are resource relationships in the dashboard, support for working in GitHub Codespaces, and publishing resources as a Dockerfile. -If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/dotnet/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://discord.com/invite/h87kDAHQgJ) to chat with team members. +If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/microsoft/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://discord.com/invite/h87kDAHQgJ) to chat with team members. Whether you're new to Aspire or have been with us since the preview, it's important to note that Aspire releases out-of-band from .NET releases. While major versions of Aspire align with .NET major versions, minor versions are released more frequently. For more details on .NET and Aspire version support, see: @@ -39,7 +39,7 @@ Moving between minor releases of Aspire is simple: ``` - For more information, see [Aspire SDK](xref:dotnet/aspire/sdk). + For more information, see [Aspire SDK](xref:microsoft/aspire/sdk). 1. Check for any NuGet package updates, either using the NuGet Package Manager in Visual Studio or the **Update NuGet Package** command in VS Code. 1. Update to the latest [Aspire templates](../fundamentals/aspire-sdk-templates.md) by running the following .NET command line: @@ -89,7 +89,7 @@ Now you use this feature to reset the dashboard to a blank slate, test your app, We 💜 love the developer community and thrive on its feedback, collaboration, and contributions. This feature is a community contribution from [@Daluur](https://github.com/Daluur). Join us in celebrating their contribution by using the feature! > [!TIP] -> If you're interested in contributing to Aspire, look for issues labeled with [good first issue](https://github.com/dotnet/aspire/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22) and follow the [contributor guide](https://github.com/dotnet/aspire/blob/main/docs/contributing.md). +> If you're interested in contributing to Aspire, look for issues labeled with [good first issue](https://github.com/microsoft/aspire/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22) and follow the [contributor guide](https://github.com/microsoft/aspire/blob/main/docs/contributing.md). ### 🔢 New filtering @@ -149,11 +149,11 @@ While this API was available in previous versions, it couldn't be used with giving you ## 🎯 Upgrade today -Follow the directions outlined in the [Upgrade to Aspire 9.1](#️-upgrade-to-net-aspire-91) section to make the switch to 9.1 and take advantage of all these new features today! As always, we're listening for your feedback on [GitHub](https://github.com/dotnet/aspire/issues)-and looking out for what you want to see in 9.2 ☺️. +Follow the directions outlined in the [Upgrade to Aspire 9.1](#️-upgrade-to-net-aspire-91) section to make the switch to 9.1 and take advantage of all these new features today! As always, we're listening for your feedback on [GitHub](https://github.com/microsoft/aspire/issues)-and looking out for what you want to see in 9.2 ☺️. -For a complete list of issues addressed in this release, see [Aspire GitHub repository—9.1 milestone](https://github.com/dotnet/aspire/issues?q=is%3Aissue%20state%3Aclosed%20milestone%3A9.1%20). \ No newline at end of file +For a complete list of issues addressed in this release, see [Aspire GitHub repository—9.1 milestone](https://github.com/microsoft/aspire/issues?q=is%3Aissue%20state%3Aclosed%20milestone%3A9.1%20). \ No newline at end of file diff --git a/tools/ReleaseNotes/data/whats-new-92.md b/tools/ReleaseNotes/data/whats-new-92.md index 593aee7a13e..010c9323b14 100644 --- a/tools/ReleaseNotes/data/whats-new-92.md +++ b/tools/ReleaseNotes/data/whats-new-92.md @@ -11,7 +11,7 @@ ms.date: 04/10/2025 - .NET 8.0 Long Term Support (LTS) - .NET 9.0 Standard Term Support (STS) -If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/dotnet/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://discord.com/invite/h87kDAHQgJ) to chat with team members. +If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/microsoft/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://discord.com/invite/h87kDAHQgJ) to chat with team members. It's important to note that Aspire releases out-of-band from .NET releases. While major versions of Aspire align with .NET major versions, minor versions are released more frequently. For more information on .NET and Aspire version support, see: @@ -50,7 +50,7 @@ Moving between minor releases of Aspire is simple: > [!IMPORTANT] > The `IsAspireHost` property is no longer required in the project file. For more information, see [🚧 Project file changes](#-project-file-changes). - For more information, see [Aspire SDK](xref:dotnet/aspire/sdk). + For more information, see [Aspire SDK](xref:microsoft/aspire/sdk). 1. Check for any NuGet package updates, either using the NuGet Package Manager in Visual Studio or the **Update NuGet Package** command in VS Code. 1. Update to the latest [Aspire templates](../fundamentals/aspire-sdk-templates.md) by running the following .NET command line: @@ -70,7 +70,7 @@ The [app host](../fundamentals/app-host-overview.md) is the core of Aspire, prov ### 🚧 Project file changes -The Aspire app host project file no longer requires the `IsAspireHost` property. This property was moved to the `Aspire.AppHost.Sdk` SDK, therefore, you can remove it from your project file. For more information, see [dotnet/aspire issue #8144](https://github.com/dotnet/aspire/pull/8144). +The Aspire app host project file no longer requires the `IsAspireHost` property. This property was moved to the `Aspire.AppHost.Sdk` SDK, therefore, you can remove it from your project file. For more information, see [microsoft/aspire issue #8144](https://github.com/microsoft/aspire/pull/8144). ### 🔗 Define custom resource URLs @@ -209,7 +209,7 @@ The Redis, Valkey, and Garnet containers enable password authentication by defau ### 💾 Automatic database creation support -There's [plenty of feedback and confusion](https://github.com/dotnet/aspire/issues/7101) around the `AddDatabase` API. The name implies that it adds a database, but it didn't actually create the database. In Aspire 9.2, the `AddDatabase` API now creates a database for the following hosting integrations: +There's [plenty of feedback and confusion](https://github.com/microsoft/aspire/issues/7101) around the `AddDatabase` API. The name implies that it adds a database, but it didn't actually create the database. In Aspire 9.2, the `AddDatabase` API now creates a database for the following hosting integrations: | Hosting integration | API reference | |--|--| diff --git a/tools/ReleaseNotes/data/whats-new-93.md b/tools/ReleaseNotes/data/whats-new-93.md index e37a2772d16..396d4534914 100644 --- a/tools/ReleaseNotes/data/whats-new-93.md +++ b/tools/ReleaseNotes/data/whats-new-93.md @@ -11,7 +11,7 @@ ms.date: 05/18/2025 - .NET 8.0 Long Term Support (LTS) - .NET 9.0 Standard Term Support (STS) -If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/dotnet/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://aka.ms/dotnet-discord) to chat with team members. +If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/microsoft/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://aka.ms/dotnet-discord) to chat with team members. It's important to note that Aspire releases out-of-band from .NET releases. While major versions of Aspire align with major .NET versions, minor versions are released more frequently. For more information on .NET and Aspire version support, see: @@ -98,7 +98,7 @@ builder.Eventing.Subscribe(myCustom, async (e, ct) => }); ``` -This replaces awkward patterns like `Task.Run` inside constructors or `Configure()` methods. You can see a more complex version in the [TalkingClock sample](https://github.com/dotnet/aspire-samples/tree/3dee8cd7c7880fe421ea61ba167301eb1369000a/samples/CustomResources/CustomResources.AppHost) in the official Aspire samples repo. +This replaces awkward patterns like `Task.Run` inside constructors or `Configure()` methods. You can see a more complex version in the [TalkingClock sample](https://github.com/microsoft/aspire-samples/tree/3dee8cd7c7880fe421ea61ba167301eb1369000a/samples/CustomResources/CustomResources.AppHost) in the official Aspire samples repo. #### `ResourceEndpointsAllocatedEvent` @@ -811,7 +811,7 @@ This ensures every app that references the database gets **full access** without If your deployment relied on Aspire setting the managed identity as the SQL Server **admin**, you'll need to review your access model. Apps now receive **explicit role-based access (`db_owner`)** instead of broad admin rights. -📖 Related: [dotnet/aspire#8381](https://github.com/dotnet/aspire/issues/8381) and [dotnet/aspire#8389](https://github.com/dotnet/aspire/issues/8389) +📖 Related: [microsoft/aspire#8381](https://github.com/microsoft/aspire/issues/8381) and [microsoft/aspire#8389](https://github.com/microsoft/aspire/issues/8389) ### 💸 Default Azure SQL SKU now uses the Free Offer (Breaking change) @@ -840,7 +840,7 @@ sql.AddDatabase("appdb") .WithDefaultAzureSku(); // Uses the previous (General Purpose) default ``` -If you want to specify what SKU to use, you the `ConfigureInfrastructure` method as explained here: [Setting a specific SKU](https://github.com/dotnet/aspire/tree/main/src/Aspire.Hosting.Azure.Sql#setting-a-specific-sku). +If you want to specify what SKU to use, you the `ConfigureInfrastructure` method as explained here: [Setting a specific SKU](https://github.com/microsoft/aspire/tree/main/src/Aspire.Hosting.Azure.Sql#setting-a-specific-sku). #### ⚠️ Breaking change diff --git a/tools/ReleaseNotes/data/whats-new-94.md b/tools/ReleaseNotes/data/whats-new-94.md index 26487344949..33021957524 100644 --- a/tools/ReleaseNotes/data/whats-new-94.md +++ b/tools/ReleaseNotes/data/whats-new-94.md @@ -12,7 +12,7 @@ ms.date: 07/29/2025 - .NET 9.0 Standard Term Support (STS) - .NET 10.0 Preview 6 -If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/dotnet/aspire) or join us on our new [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://aka.ms/aspire-discord) to chat with the team and other community members. +If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/microsoft/aspire) or join us on our new [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://aka.ms/aspire-discord) to chat with the team and other community members. It's important to note that Aspire releases out-of-band from .NET releases. While major versions of Aspire align with major .NET versions, minor versions are released more frequently. For more information on .NET and Aspire version support, see: @@ -29,7 +29,7 @@ Moving between minor releases of Aspire is simple: ``` - For more information, see [Aspire SDK](xref:dotnet/aspire/sdk). + For more information, see [Aspire SDK](xref:microsoft/aspire/sdk). 1. Check for any NuGet package updates, either using the NuGet Package Manager in Visual Studio or the **Update NuGet Package** command from C# Dev Kit in VS Code. 1. Update to the latest [Aspire templates](../fundamentals/aspire-sdk-templates.md) by running the following .NET command line: @@ -913,7 +913,7 @@ When a newer version is detected, a friendly notification appears in the Aspire :::image type="content" source="media/dashboard-update-notification.png" lightbox="media/dashboard-update-notification.png" alt-text="Screenshot of dashboard showing an update notification."::: -Aspire only shows notifications when a newer version is available, and the checks happen in the background without impacting application startup or performance. The upgrade check system can be disable by setting the `ASPIRE_VERSION_CHECK_DISABLED` environment variable to `true`. For more information, see [App host configuration](/dotnet/aspire/app-host/configuration). +Aspire only shows notifications when a newer version is available, and the checks happen in the background without impacting application startup or performance. The upgrade check system can be disable by setting the `ASPIRE_VERSION_CHECK_DISABLED` environment variable to `true`. For more information, see [App host configuration](/microsoft/aspire/app-host/configuration). ### 📋 Parameters and connection strings visible in dashboard @@ -931,7 +931,7 @@ External parameters are no longer hidden. The parameter state and value is visib :::image type="content" source="media/dashboard-parameters.png" lightbox="media/dashboard-parameters.png" alt-text="Screenshot of dashboard showing parameters."::: -For more information, see [external parameters](/dotnet/aspire/fundamentals/external-parameters). +For more information, see [external parameters](/microsoft/aspire/fundamentals/external-parameters). ### 🔗 Enhanced dashboard peer visualization for uninstrumented resources @@ -954,7 +954,7 @@ Aspire 9.4 introduces a new toggle option in the dashboard console logs to contr :::image type="content" source="media/dashboard-console-logs-wrapping.gif" lightbox="media/dashboard-console-logs-wrapping.gif" alt-text="Recording of toggling line wrapping on console logs page."::: -Some Aspire users have run into trouble with viewing large console logs, which is tracked in this GitHub issue: [Console logs not showing, plus browser window size affecting displayed logs #7969](https://github.com/dotnet/aspire/issues/7969). If you're having trouble with logs please try experimenting with disabling wrapping and see whether it improves your user experience. Feedback on this issue would be very helpful. +Some Aspire users have run into trouble with viewing large console logs, which is tracked in this GitHub issue: [Console logs not showing, plus browser window size affecting displayed logs #7969](https://github.com/microsoft/aspire/issues/7969). If you're having trouble with logs please try experimenting with disabling wrapping and see whether it improves your user experience. Feedback on this issue would be very helpful. ### 👁️ Show/hide hidden resources in dashboard @@ -1820,7 +1820,7 @@ var resource = builder.AddAzureInfrastructure("custom", infra => }); ``` -**Migration impact**: Replace auto-injected parameters with explicit resource modeling for better resource graph representation and support for multiple Azure compute environments. See [Azure resource customization docs](https://learn.microsoft.com/dotnet/aspire/azure/customize-azure-resources) for more details. +**Migration impact**: Replace auto-injected parameters with explicit resource modeling for better resource graph representation and support for multiple Azure compute environments. See [Azure resource customization docs](https://learn.microsoft.com/microsoft/aspire/azure/customize-azure-resources) for more details. ### 🔧 ParameterResource.Value synchronous behavior change @@ -1867,6 +1867,6 @@ With every release, we strive to make Aspire better. However, some changes may b ## 🎯 Upgrade today -Follow the directions outlined in the [Upgrade to Aspire 9.4](#️-upgrade-to-net-aspire-94) section to make the switch to 9.4 and take advantage of all these new features today! As always, we're listening for your feedback on [GitHub](https://github.com/dotnet/aspire/issues)—and looking out for what you want to see in 9.5 ☺️. +Follow the directions outlined in the [Upgrade to Aspire 9.4](#️-upgrade-to-net-aspire-94) section to make the switch to 9.4 and take advantage of all these new features today! As always, we're listening for your feedback on [GitHub](https://github.com/microsoft/aspire/issues)—and looking out for what you want to see in 9.5 ☺️. -For a complete list of issues addressed in this release, see [Aspire GitHub repository—9.4 milestone](https://github.com/dotnet/aspire/issues?q=is%3Aissue%20state%3Aclosed%20milestone%3A9.4%20). +For a complete list of issues addressed in this release, see [Aspire GitHub repository—9.4 milestone](https://github.com/microsoft/aspire/issues?q=is%3Aissue%20state%3Aclosed%20milestone%3A9.4%20). diff --git a/tools/ReleaseNotes/data/whats-new-95.md b/tools/ReleaseNotes/data/whats-new-95.md index 366c938b921..c9eddd0a3ea 100644 --- a/tools/ReleaseNotes/data/whats-new-95.md +++ b/tools/ReleaseNotes/data/whats-new-95.md @@ -12,7 +12,7 @@ ms.date: 09/17/2025 - .NET 9.0 Standard Term Support (STS) - .NET 10.0 RC (release candidate) 1 -If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/dotnet/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://aka.ms/aspire-discord) to chat with the team and other community members. +If you have feedback, questions, or want to contribute to Aspire, collaborate with us on [:::image type="icon" source="../media/github-mark.svg" border="false"::: GitHub](https://github.com/microsoft/aspire) or join us on [:::image type="icon" source="../media/discord-icon.svg" border="false"::: Discord](https://aka.ms/aspire-discord) to chat with the team and other community members. It's important to note that Aspire releases out-of-band from .NET releases. While major versions of Aspire align with major .NET versions, minor versions are released more frequently. For more information on .NET and Aspire version support, see: @@ -83,7 +83,7 @@ It's important to note that Aspire releases out-of-band from .NET releases. Whil ## Upgrade to Aspire 9.5 > [!NOTE] Try out the new update command! -> Aspire 9.5 brings a new preview CLI command - [aspire update](#new-aspire-update-command-preview) - that can update your AppHost and its packages for you. Get the latest CLI if you want to try and give us feedback about it on [GitHub](https://github.com/dotnet/aspire/issues)! +> Aspire 9.5 brings a new preview CLI command - [aspire update](#new-aspire-update-command-preview) - that can update your AppHost and its packages for you. Get the latest CLI if you want to try and give us feedback about it on [GitHub](https://github.com/microsoft/aspire/issues)! Moving between minor releases of Aspire is simple: @@ -103,7 +103,7 @@ Moving between minor releases of Aspire is simple: ``` - For more information, see [Aspire SDK](xref:dotnet/aspire/sdk). + For more information, see [Aspire SDK](xref:microsoft/aspire/sdk). 1. Check for any NuGet package updates, either using the NuGet Package Manager in Visual Studio or the **Update NuGet Package** command from C# Dev Kit in VS Code. @@ -343,7 +343,7 @@ Several improvements to resource management and debugging capabilities: - **Sub-menu organization**: Resource action menus now use sub-menus to prevent overflow on complex applications (#10869) - **Launch profile details**: Project resources now show their associated launch profile for easier debugging (#10906) - **Improved navigation**: Better resource selection and navigation handling (#10848) -- **Launch profile localization**: Launch profile localization and model surfaced in dashboard resource details ([#10906](https://github.com/dotnet/aspire/pull/10906)) +- **Launch profile localization**: Launch profile localization and model surfaced in dashboard resource details ([#10906](https://github.com/microsoft/aspire/pull/10906)) **Debugging enhancements:** - **Direct launch profile access**: Quick access to the launch configuration used for each project @@ -1059,7 +1059,7 @@ var worker = builder.AddProject("worker") .WithReference(database); ``` -New `ResourceStoppedEvent` provides lifecycle insight when resources shut down or fail ([#11103](https://github.com/dotnet/aspire/pull/11103)): +New `ResourceStoppedEvent` provides lifecycle insight when resources shut down or fail ([#11103](https://github.com/microsoft/aspire/pull/11103)): ```csharp builder.AddProject("api") @@ -1463,18 +1463,18 @@ These overloads provide convenient APIs for the most common job types while main 9.5 delivers the first iteration of the Azure provisioning & deployment pipeline that unifies interactive prompting, Bicep compilation, and mode-specific behavior (run vs publish) across Azure resources: -- New provisioning contexts separate run-mode and publish-mode flows ([#11094](https://github.com/dotnet/aspire/pull/11094)). +- New provisioning contexts separate run-mode and publish-mode flows ([#11094](https://github.com/microsoft/aspire/pull/11094)). - Graph-based dependency planning (`ResourceDeploymentGraph`) ensures correct ordering of resource provisioning. -- Improved error handling and idempotency for `AddAsExistingResource` across all Azure resources ([#10562](https://github.com/dotnet/aspire/issues/10562)). -- Support for deploying compute images and resources (custom images referenced in your environment) ([#11030](https://github.com/dotnet/aspire/pull/11030)). -- Deploy individual Bicep modules instead of a monolithic `main.bicep` for clearer failure isolation and faster iteration ([#11098](https://github.com/dotnet/aspire/pull/11098)). +- Improved error handling and idempotency for `AddAsExistingResource` across all Azure resources ([#10562](https://github.com/microsoft/aspire/issues/10562)). +- Support for deploying compute images and resources (custom images referenced in your environment) ([#11030](https://github.com/microsoft/aspire/pull/11030)). +- Deploy individual Bicep modules instead of a monolithic `main.bicep` for clearer failure isolation and faster iteration ([#11098](https://github.com/microsoft/aspire/pull/11098)). - Localized interaction + notification strings across all provisioning prompts (multiple OneLocBuild PRs). Provisioning automatically prompts for required values only once per run, caches results, and reuses them in publish-mode without re-prompting. This reduces friction when iterating locally while maintaining reproducibility for production publish. ### Azure deployer interactive command handling -The AppHost now wires Azure provisioning prompts into the standard interaction system (initial work in [#10038](https://github.com/dotnet/aspire/pull/10038), extended in [#10792](https://github.com/dotnet/aspire/pull/10792) and [#10845](https://github.com/dotnet/aspire/pull/10845)). This enables: +The AppHost now wires Azure provisioning prompts into the standard interaction system (initial work in [#10038](https://github.com/microsoft/aspire/pull/10038), extended in [#10792](https://github.com/microsoft/aspire/pull/10792) and [#10845](https://github.com/microsoft/aspire/pull/10845)). This enables: - Consistent UX for parameter entry (names, descriptions, validation) - Localized prompt text @@ -1482,15 +1482,15 @@ The AppHost now wires Azure provisioning prompts into the standard interaction s ### Azure resource idempotency & existing resources -Calling `AddAsExistingResource` is now idempotent across Azure hosting resource builders; repeated calls no longer cause duplicate annotations or inconsistent behavior ([#10562](https://github.com/dotnet/aspire/issues/10562)). This improves reliability when composing reusable extension methods. +Calling `AddAsExistingResource` is now idempotent across Azure hosting resource builders; repeated calls no longer cause duplicate annotations or inconsistent behavior ([#10562](https://github.com/microsoft/aspire/issues/10562)). This improves reliability when composing reusable extension methods. ### Compute image deployment -You can now reference and deploy custom compute images as part of Azure environment provisioning ([#11030](https://github.com/dotnet/aspire/pull/11030)). This lays groundwork for richer VM/container hybrid topologies. +You can now reference and deploy custom compute images as part of Azure environment provisioning ([#11030](https://github.com/microsoft/aspire/pull/11030)). This lays groundwork for richer VM/container hybrid topologies. ### Module-scoped Bicep deployment -Instead of generating a single aggregated template, 9.5 deploys individual Bicep modules ([#11098](https://github.com/dotnet/aspire/pull/11098)). Failures surface with more precise context and partial successes require less rework. +Instead of generating a single aggregated template, 9.5 deploys individual Bicep modules ([#11098](https://github.com/microsoft/aspire/pull/11098)). Failures surface with more precise context and partial successes require less rework. ### Publishing progress & activity reporting @@ -1498,11 +1498,11 @@ Instead of generating a single aggregated template, 9.5 deploys individual Bicep ### Parameter & interaction API updates -- `ParameterResource.Value` is now obsolete: switch to `await parameter.GetValueAsync()` or inject parameter resources directly ([#10363](https://github.com/dotnet/aspire/pull/10363)). This change improves async value acquisition and avoids accidental blocking. -- Interaction inputs enforce server-side validation and required `Name` property (breaking, [#10835](https://github.com/dotnet/aspire/pull/10835)). -- New notification terminology (renamed from MessageBar, [#10449](https://github.com/dotnet/aspire/pull/10449)). +- `ParameterResource.Value` is now obsolete: switch to `await parameter.GetValueAsync()` or inject parameter resources directly ([#10363](https://github.com/microsoft/aspire/pull/10363)). This change improves async value acquisition and avoids accidental blocking. +- Interaction inputs enforce server-side validation and required `Name` property (breaking, [#10835](https://github.com/microsoft/aspire/pull/10835)). +- New notification terminology (renamed from MessageBar, [#10449](https://github.com/microsoft/aspire/pull/10449)). - `ExecuteCommandResult` now includes a `Canceled` property to track whether command execution was canceled by the user or system. -- Server-side validation of interaction inputs ([#10527](https://github.com/dotnet/aspire/pull/10527)). +- Server-side validation of interaction inputs ([#10527](https://github.com/microsoft/aspire/pull/10527)). Migration example: @@ -1647,7 +1647,7 @@ The `InteractionInputCollection` provides indexed access by name and improved ty ### Docker Compose Aspire Dashboard forwarding headers -`AddDockerComposeEnvironment(...).WithDashboard()` gained `WithForwardedHeaders()` to enable forwarded `Host` and `Proto` handling for dashboard scenarios behind reverse proxies or compose networks ([#11080](https://github.com/dotnet/aspire/pull/11080)). This mirrors the standalone dashboard forwarded header support and fixes auth redirect edge cases. +`AddDockerComposeEnvironment(...).WithDashboard()` gained `WithForwardedHeaders()` to enable forwarded `Host` and `Proto` handling for dashboard scenarios behind reverse proxies or compose networks ([#11080](https://github.com/microsoft/aspire/pull/11080)). This mirrors the standalone dashboard forwarded header support and fixes auth redirect edge cases. ```csharp builder.AddDockerComposeEnvironment("env") @@ -1657,7 +1657,7 @@ builder.AddDockerComposeEnvironment("env") ### Container build customization -`ContainerBuildOptions` support (commit [#10074](https://github.com/dotnet/aspire/pull/10074)) enables customizing the underlying `dotnet publish` invocation when Aspire builds project-sourced container images (for example to change configuration, trimming, or pass additional MSBuild properties). Use the new options hook on the project container image configuration to set MSBuild properties instead of maintaining a custom Dockerfile. (Exact API surface is intentionally summarized here to avoid drift; see API docs for `ContainerBuildOptions` in the hosting namespace for usage.) +`ContainerBuildOptions` support (commit [#10074](https://github.com/microsoft/aspire/pull/10074)) enables customizing the underlying `dotnet publish` invocation when Aspire builds project-sourced container images (for example to change configuration, trimming, or pass additional MSBuild properties). Use the new options hook on the project container image configuration to set MSBuild properties instead of maintaining a custom Dockerfile. (Exact API surface is intentionally summarized here to avoid drift; see API docs for `ContainerBuildOptions` in the hosting namespace for usage.) ### Deployment image tag callbacks diff --git a/tools/ReleaseNotes/docs/api-documentation.md b/tools/ReleaseNotes/docs/api-documentation.md index 7e461fffeaa..53081722113 100644 --- a/tools/ReleaseNotes/docs/api-documentation.md +++ b/tools/ReleaseNotes/docs/api-documentation.md @@ -119,7 +119,7 @@ analysis-output/Aspire.Cli.md ### Find Related Documentation - Using the MicrosoftDocs MCP, search for existing documentation about the feature, starting with Aspire documentation. -- Documentation can be referenced in multiple ways. If the doc is part of the aspire docset (learn.microsoft.com/dotnet/aspire/*) you can use a relative path (assume What's New is one level - ie ../ - below "root" dotnet/aspire/) +- Documentation can be referenced in multiple ways. If the doc is part of the aspire docset (learn.microsoft.com/microsoft/aspire/*) you can use a relative path (assume What's New is one level - ie ../ - below "root" microsoft/aspire/) - If the docset is on learn.microsoft.com, but not from Aspire, you can use an xref in the link path - for example, something under Azure docs (learn.microsoft.com/azure/ai-foundry/overview) would be [Microsoft Foundry documentation](xref:/azure/ai-foundry/overview) - If a new API is explicitly called out, use an xref to the API docs via the fully qualified API namespace. For example, `Aspire.Hosting.ApplicationModel.BeforeStartEvent` or simply `BeforeStartEvent` becomes - Do NOT put links to docs or APIs in the sample code. Only put them in the brief description above to set context, or the explanation for follow up content and API docs. diff --git a/tools/ReleaseNotes/docs/commit-analysis.md b/tools/ReleaseNotes/docs/commit-analysis.md index ada432788af..28cb40487fb 100644 --- a/tools/ReleaseNotes/docs/commit-analysis.md +++ b/tools/ReleaseNotes/docs/commit-analysis.md @@ -72,7 +72,7 @@ c5e604f4b Add dashboard resource to AddDockerComposeEnvironment (#9597) # Enhanced Feature Documentation: ### ⚡ Faster aspire exec validation -The `aspire exec` command now provides immediate validation feedback, failing fast when required arguments are missing instead of spending time searching for projects first. Error messages have also been improved to be more actionable ([#10606](https://github.com/dotnet/aspire/pull/10606)). +The `aspire exec` command now provides immediate validation feedback, failing fast when required arguments are missing instead of spending time searching for projects first. Error messages have also been improved to be more actionable ([#10606](https://github.com/microsoft/aspire/pull/10606)). **Before:** CLI searches for projects, then shows confusing "Failed to parse command" error **After:** Immediate "Target resource is not specified" error with clear guidance @@ -95,7 +95,7 @@ This improvement reduces development friction by providing faster, clearer feedb # Final documentation includes GitHub reference: ### ✨ Enhanced telemetry navigation -The dashboard now provides better navigation between telemetry data and resources ([#10648](https://github.com/dotnet/aspire/pull/10648)). +The dashboard now provides better navigation between telemetry data and resources ([#10648](https://github.com/microsoft/aspire/pull/10648)). ``` #### GitHub Issue Pattern Recognition diff --git a/tools/scripts/DownloadFailingJobLogs.cs b/tools/scripts/DownloadFailingJobLogs.cs index 2043d8aa0ed..e216eddcc18 100644 --- a/tools/scripts/DownloadFailingJobLogs.cs +++ b/tools/scripts/DownloadFailingJobLogs.cs @@ -14,7 +14,7 @@ } var runId = args[0]; -var repo = "dotnet/aspire"; +var repo = "microsoft/aspire"; Console.WriteLine($"Finding failed jobs for run {runId}..."); diff --git a/tools/scripts/README.md b/tools/scripts/README.md index 129867045da..56940826259 100644 --- a/tools/scripts/README.md +++ b/tools/scripts/README.md @@ -21,7 +21,7 @@ This tool helps you quickly investigate GitHub Actions test failures by: - .NET 10 SDK or later - GitHub CLI (`gh`) installed and authenticated -- Access to the dotnet/aspire repository (or appropriate permissions for your target repo) +- Access to the microsoft/aspire repository (or appropriate permissions for your target repo) ### Usage @@ -38,7 +38,7 @@ dotnet tools/scripts/DownloadFailingJobLogs.cs 19846215629 You can find the run ID from the GitHub Actions URL: ``` -https://github.com/dotnet/aspire/actions/runs/19846215629 +https://github.com/microsoft/aspire/actions/runs/19846215629 ^^^^^^^^^^ run ID ``` @@ -65,7 +65,7 @@ Found 1 failed jobs === Failed Job 1/1 === Name: Tests / Integrations macos (Hosting.Azure) / Hosting.Azure (macos-latest) ID: 56864254427 -URL: https://github.com/dotnet/aspire/actions/runs/19846215629/job/56864254427 +URL: https://github.com/microsoft/aspire/actions/runs/19846215629/job/56864254427 Downloading job logs... Saved job logs to: failed_job_0_Tests___Integrations_macos__Hosting_Azure____Hosting_Azure__macos-latest_.log (354209 characters) From f9a8c6388ebfe844d7fef3dd7159eeeee6030ebe Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Tue, 24 Mar 2026 11:58:23 +1100 Subject: [PATCH 32/49] Quarantine Docker and Kubernetes E2E tests on release/13.2 (#15512) * Quarantine Docker and Kubernetes E2E tests on release/13.2 SuppressFinalPackageVersion=true packages get assembly version 42.42.42.42 while stable packages resolve from nuget.org with 13.2.0.0, causing CS1705 and NU1102 errors on release branches. Tracking issue: https://github.com/microsoft/aspire/issues/15511 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add missing 'using Aspire.TestUtilities' for QuarantinedTest attribute Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs | 3 +++ tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs index a6d32122da5..0c820bb9a77 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs @@ -3,6 +3,7 @@ using Aspire.Cli.EndToEnd.Tests.Helpers; using Aspire.Cli.Tests.Utils; +using Aspire.TestUtilities; using Hex1b.Automation; using Xunit; @@ -18,6 +19,7 @@ public sealed class DockerDeploymentTests(ITestOutputHelper output) private const string ProjectName = "AspireDockerDeployTest"; [Fact] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/15511")] public async Task CreateAndDeployToDockerCompose() { using var workspace = TemporaryWorkspace.Create(output); @@ -139,6 +141,7 @@ public async Task CreateAndDeployToDockerCompose() } [Fact] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/15511")] public async Task CreateAndDeployToDockerComposeInteractive() { using var workspace = TemporaryWorkspace.Create(output); diff --git a/tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs index 616ac1986f6..75ab3466ea7 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs @@ -3,6 +3,7 @@ using Aspire.Cli.EndToEnd.Tests.Helpers; using Aspire.Cli.Tests.Utils; +using Aspire.TestUtilities; using Hex1b.Automation; using Xunit; @@ -26,6 +27,7 @@ private static string GenerateUniqueClusterName() => $"{ClusterNamePrefix}-{Guid.NewGuid():N}"[..32]; // KinD cluster names max 32 chars [Fact] + [QuarantinedTest("https://github.com/microsoft/aspire/issues/15511")] public async Task CreateAndPublishToKubernetes() { using var workspace = TemporaryWorkspace.Create(output); From 9134219785108d5ebd69fc81e0c918ff94636124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Mon, 23 Mar 2026 18:00:29 -0700 Subject: [PATCH 33/49] [release/13.2] Pin Kusto emulator image and backport Cosmos fix (#15504) * Tighten Kusto emulator functional log assertions (#15473) * Tighten Kusto functional log assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Document Kusto log assertion source Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Assert Kusto failure log message Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix Kusto assertion analyzer warning Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Re-enable Kusto Linux tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Relax Kusto invalid log assertion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Strengthen Kusto failure log assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Relax Kusto exception assertion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Reduce Cosmos emulator test footprint Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Scope Cosmos wait test health checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Harden Cosmos emulator readiness Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Pin classic Cosmos emulator image Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use Cosmos emulator 2.14.26 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use stable Cosmos emulator image Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 75c45a3ff59397362ee89046ee401203580ee0be) * Adjust Cosmos emulator tag test for stable backport Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Pin Kusto emulator image on release/13.2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CosmosDBEmulatorContainerImageTags.cs | 4 ++-- .../AzureKustoEmulatorContainerImageTags.cs | 4 ++-- tests/Aspire.Hosting.Azure.Kusto.Tests/AddAzureKustoTests.cs | 2 +- .../AzureCosmosDBExtensionsTests.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Aspire.Hosting.Azure.CosmosDB/CosmosDBEmulatorContainerImageTags.cs b/src/Aspire.Hosting.Azure.CosmosDB/CosmosDBEmulatorContainerImageTags.cs index 5644cbf278b..864c5a99fd5 100644 --- a/src/Aspire.Hosting.Azure.CosmosDB/CosmosDBEmulatorContainerImageTags.cs +++ b/src/Aspire.Hosting.Azure.CosmosDB/CosmosDBEmulatorContainerImageTags.cs @@ -11,8 +11,8 @@ internal static class CosmosDBEmulatorContainerImageTags /// cosmosdb/linux/azure-cosmos-emulator public const string Image = "cosmosdb/linux/azure-cosmos-emulator"; - /// latest - public const string Tag = "latest"; + /// stable + public const string Tag = "stable"; /// vnext-preview public const string TagVNextPreview = "vnext-preview"; diff --git a/src/Aspire.Hosting.Azure.Kusto/AzureKustoEmulatorContainerImageTags.cs b/src/Aspire.Hosting.Azure.Kusto/AzureKustoEmulatorContainerImageTags.cs index 3a6cf44fec9..2b9f43ed83e 100644 --- a/src/Aspire.Hosting.Azure.Kusto/AzureKustoEmulatorContainerImageTags.cs +++ b/src/Aspire.Hosting.Azure.Kusto/AzureKustoEmulatorContainerImageTags.cs @@ -23,6 +23,6 @@ internal static class AzureKustoEmulatorContainerImageTags /// /// The tag for the Kusto emulator container image. /// - /// latest - public static string Tag { get; } = "latest"; + /// 2026.03.16.1116-2611-994a3c9-master + public static string Tag { get; } = "2026.03.16.1116-2611-994a3c9-master"; } diff --git a/tests/Aspire.Hosting.Azure.Kusto.Tests/AddAzureKustoTests.cs b/tests/Aspire.Hosting.Azure.Kusto.Tests/AddAzureKustoTests.cs index c921cddf0a4..b029174d695 100644 --- a/tests/Aspire.Hosting.Azure.Kusto.Tests/AddAzureKustoTests.cs +++ b/tests/Aspire.Hosting.Azure.Kusto.Tests/AddAzureKustoTests.cs @@ -27,7 +27,7 @@ public void AddAzureKustoCluster_ShouldCreateAzureKustoClusterResourceWithCorrec } [Theory] - [InlineData(null, "latest")] + [InlineData(null, "2026.03.16.1116-2611-994a3c9-master")] [InlineData("custom-tag", "custom-tag")] public void RunAsEmulator_ShouldConfigureContainerImageWithCorrectTag(string? customTag, string expectedTag) { diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs index 493b3d25b37..3b6d74fe9ed 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs @@ -58,7 +58,7 @@ public void AddAzureCosmosDBWithEmulatorGetsExpectedImageTag(string imageTag) Assert.NotNull(containerImageAnnotation); var actualTag = containerImageAnnotation.Tag; - Assert.Equal(imageTag ?? "latest", actualTag); + Assert.Equal(imageTag ?? "stable", actualTag); } [Theory] From 276dd6b0a5e8f043abaeb206b896fc88f85196bc Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 25 Mar 2026 06:55:11 +0800 Subject: [PATCH 34/49] Strip /login path from dashboard base URL in describe command (#15495) The describe command was passing BaseUrlWithLoginToken (e.g., http://localhost:18888/login?t=token) directly to the resource snapshot mapper, producing broken dashboard URLs like http://localhost:18888/login?t=token/?resource=redis. Reuse TelemetryCommandHelpers.ExtractDashboardBaseUrl to strip the /login?t=... path before combining with resource URLs. --- src/Aspire.Cli/Commands/DescribeCommand.cs | 2 +- .../Commands/TelemetryCommandHelpers.cs | 2 +- .../Commands/DescribeCommandTests.cs | 65 ++++++++++++++++++- 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/Aspire.Cli/Commands/DescribeCommand.cs b/src/Aspire.Cli/Commands/DescribeCommand.cs index 45bed5dfcfe..50733fda462 100644 --- a/src/Aspire.Cli/Commands/DescribeCommand.cs +++ b/src/Aspire.Cli/Commands/DescribeCommand.cs @@ -142,7 +142,7 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell await Task.WhenAll(dashboardUrlsTask, snapshotsTask).ConfigureAwait(false); - var dashboardBaseUrl = (await dashboardUrlsTask.ConfigureAwait(false))?.BaseUrlWithLoginToken; + var dashboardBaseUrl = TelemetryCommandHelpers.ExtractDashboardBaseUrl((await dashboardUrlsTask.ConfigureAwait(false))?.BaseUrlWithLoginToken); var snapshots = await snapshotsTask.ConfigureAwait(false); // Pre-resolve colors for all resource names so that assignment is diff --git a/src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs b/src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs index 99daad6f807..b327cd2476a 100644 --- a/src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs +++ b/src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs @@ -136,7 +136,7 @@ public static bool HasJsonContentType(HttpResponseMessage response) /// /// Extracts the base URL from a dashboard URL (removes /login?t=... path). /// - private static string? ExtractDashboardBaseUrl(string? dashboardUrlWithToken) + internal static string? ExtractDashboardBaseUrl(string? dashboardUrlWithToken) { if (string.IsNullOrEmpty(dashboardUrlWithToken)) { diff --git a/tests/Aspire.Cli.Tests/Commands/DescribeCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/DescribeCommandTests.cs index 2a78b9d402d..58c0a7eb120 100644 --- a/tests/Aspire.Cli.Tests/Commands/DescribeCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/DescribeCommandTests.cs @@ -331,11 +331,71 @@ public async Task DescribeCommand_Follow_TableFormat_DeduplicatesIdenticalSnapsh Assert.Equal("[redis] Stopping", resourceLines[1]); } + [Fact] + public async Task DescribeCommand_JsonFormat_StripsLoginPathFromDashboardUrl() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var outputWriter = new TestOutputTextWriter(outputHelper); + var provider = CreateDescribeTestServices(workspace, outputWriter, [ + new ResourceSnapshot { Name = "redis", DisplayName = "redis", ResourceType = "Container", State = "Running" }, + ], dashboardUrlsState: new DashboardUrlsState + { + BaseUrlWithLoginToken = "http://localhost:18888/login?t=abcd1234" + }); + + var command = provider.GetRequiredService(); + var result = command.Parse("describe --format json"); + + var exitCode = await result.InvokeAsync().DefaultTimeout(); + + Assert.Equal(ExitCodeConstants.Success, exitCode); + + var jsonOutput = string.Join("", outputWriter.Logs); + var deserialized = JsonSerializer.Deserialize(jsonOutput, ResourcesCommandJsonContext.RelaxedEscaping.ResourcesOutput); + + Assert.NotNull(deserialized); + Assert.Single(deserialized.Resources); + + Assert.Equal("http://localhost:18888/?resource=redis", deserialized.Resources[0].DashboardUrl); + } + + [Fact] + public async Task DescribeCommand_Follow_JsonFormat_StripsLoginPathFromDashboardUrl() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + var outputWriter = new TestOutputTextWriter(outputHelper); + var provider = CreateDescribeTestServices(workspace, outputWriter, [ + new ResourceSnapshot { Name = "redis", DisplayName = "redis", ResourceType = "Container", State = "Running" }, + ], dashboardUrlsState: new DashboardUrlsState + { + BaseUrlWithLoginToken = "http://localhost:18888/login?t=abcd1234" + }); + + var command = provider.GetRequiredService(); + var result = command.Parse("describe --follow --format json"); + + var exitCode = await result.InvokeAsync().DefaultTimeout(); + + Assert.Equal(ExitCodeConstants.Success, exitCode); + + var jsonLines = outputWriter.Logs + .Where(l => l.TrimStart().StartsWith("{", StringComparison.Ordinal)) + .ToList(); + + Assert.NotEmpty(jsonLines); + + var resource = JsonSerializer.Deserialize(jsonLines[0], ResourcesCommandJsonContext.Ndjson.ResourceJson); + Assert.NotNull(resource); + + Assert.Equal("http://localhost:18888/?resource=redis", resource.DashboardUrl); + } + private ServiceProvider CreateDescribeTestServices( TemporaryWorkspace workspace, TestOutputTextWriter outputWriter, List resourceSnapshots, - bool disableAnsi = false) + bool disableAnsi = false, + DashboardUrlsState? dashboardUrlsState = null) { var monitor = new TestAuxiliaryBackchannelMonitor(); var connection = new TestAppHostAuxiliaryBackchannel @@ -346,7 +406,8 @@ private ServiceProvider CreateDescribeTestServices( AppHostPath = Path.Combine(workspace.WorkspaceRoot.FullName, "TestAppHost", "TestAppHost.csproj"), ProcessId = 1234 }, - ResourceSnapshots = resourceSnapshots + ResourceSnapshots = resourceSnapshots, + DashboardUrlsState = dashboardUrlsState }; monitor.AddConnection("hash1", "socket.hash1", connection); From fd89bd121ce7d70f865f04ecf5a4e1e564360589 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:56:22 -0700 Subject: [PATCH 35/49] Bump patch version from 13.2.0 to 13.2.1 (#15555) Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/6a2f1f41-1660-4e0c-8d21-9fb0061809aa Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com> --- eng/Versions.props | 2 +- .../RepoTesting/Aspire.RepoTesting.targets | 4 +- .../Directory.Packages.Helix.props | 144 +++++++++--------- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index ffb5ea9ce7f..ee222be33f3 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -3,7 +3,7 @@ 13 2 - 0 + 1 $(MajorVersion).$(MinorVersion).$(PatchVersion) preview.1 net8.0 diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets index 7b2650bea51..c992436b4f3 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets @@ -33,7 +33,7 @@ `AspireProjectOrPackageReference` - maps to projects in `src/` or `src/Components/` --> - + @@ -165,6 +165,6 @@ $(MajorVersion).$(MinorVersion).$(PatchVersion) - + diff --git a/tests/Shared/RepoTesting/Directory.Packages.Helix.props b/tests/Shared/RepoTesting/Directory.Packages.Helix.props index 27b52defa1e..aa198622223 100644 --- a/tests/Shared/RepoTesting/Directory.Packages.Helix.props +++ b/tests/Shared/RepoTesting/Directory.Packages.Helix.props @@ -3,82 +3,82 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + From f138ea7ed13f35a12bf8e9b30e4699c5d727e8b8 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 25 Mar 2026 09:14:54 -0700 Subject: [PATCH 36/49] [release/13.2] Fix cross-compiled CLI bundles missing DCP (win-arm64, linux-arm64, linux-musl-x64) (#15529) * Fix cross-compiled bundles missing DCP for win-arm64, linux-arm64, linux-musl-x64 Bundle.proj's _RestoreDcpPackage target now maps TargetRid to BuildOs/BuildArch and passes them to the AppHost restore, ensuring the correct DCP NuGet package is downloaded for the target platform instead of the build machine's platform. CreateLayout now throws when DCP is not found instead of silently producing a broken bundle that would fail layout validation at runtime. Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/a71f0181-f863-4d63-b275-47c8eb198dee * Add validation for unrecognized RID patterns and document supported format Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/a71f0181-f863-4d63-b275-47c8eb198dee --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com> --- eng/Bundle.proj | 22 ++++++++++++++++++++-- tools/CreateLayout/Program.cs | 6 ++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/eng/Bundle.proj b/eng/Bundle.proj index 626184870d4..4f6c79f644a 100644 --- a/eng/Bundle.proj +++ b/eng/Bundle.proj @@ -106,9 +106,27 @@ <_DcpBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir)RestoreDcp.binlog + + + <_BundleBuildOs Condition="$(TargetRid.StartsWith('win-'))">windows + <_BundleBuildOs Condition="$(TargetRid.StartsWith('osx-'))">darwin + <_BundleBuildOs Condition="$(TargetRid.StartsWith('linux-musl-'))">linux-musl + <_BundleBuildOs Condition="'$(_BundleBuildOs)' == '' and $(TargetRid.StartsWith('linux-'))">linux + + <_BundleBuildArch Condition="$(TargetRid.EndsWith('-x64'))">amd64 + <_BundleBuildArch Condition="$(TargetRid.EndsWith('-arm64'))">arm64 + <_BundleBuildArch Condition="$(TargetRid.EndsWith('-x86'))">386 - - + + + diff --git a/tools/CreateLayout/Program.cs b/tools/CreateLayout/Program.cs index b04ec44e7a1..93f5af57b24 100644 --- a/tools/CreateLayout/Program.cs +++ b/tools/CreateLayout/Program.cs @@ -189,8 +189,10 @@ private Task CopyDcpAsync() var dcpPath = FindDcpPath(); if (dcpPath is null) { - Log(" WARNING: DCP not found. Skipping."); - return Task.CompletedTask; + throw new InvalidOperationException( + $"DCP package not found for RID '{_rid}'. " + + $"Ensure the DCP NuGet package for the target platform is restored before running CreateLayout. " + + $"A bundle without DCP would fail layout validation at runtime."); } var dcpDir = Path.Combine(_outputPath, "dcp"); From 4961db216cb93159ac9d0f6eb57e3b6a4d8cc224 Mon Sep 17 00:00:00 2001 From: "aspire-repo-bot[bot]" <268009190+aspire-repo-bot[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 10:19:31 -0700 Subject: [PATCH 37/49] [release/13.2] Enable CFSClean policies and use dotnet-public feed for winget CLI (#15541) * Enable CFSClean policies and use dotnet-public feed for winget CLI - Add networkIsolationPolicy: Permissive, CFSClean, CFSClean2 to the 1ES official pipeline template parameters - Switch winget CLI installation from PSGallery to dotnet-public Azure Artifacts feed to comply with CFSClean network restrictions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update eng/pipelines/templates/prepare-winget-manifest.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update eng/pipelines/azure-pipelines.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Matt Mitchell (.NET) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Ankit Jain Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- eng/pipelines/azure-pipelines.yml | 2 ++ .../templates/prepare-winget-manifest.yml | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/azure-pipelines.yml b/eng/pipelines/azure-pipelines.yml index 5850f2ee702..d6653237165 100644 --- a/eng/pipelines/azure-pipelines.yml +++ b/eng/pipelines/azure-pipelines.yml @@ -105,6 +105,8 @@ resources: extends: template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates parameters: + settings: + networkIsolationPolicy: Permissive,CFSClean,CFSClean2 featureFlags: autoEnablePREfastWithNewRuleset: false autoEnableRoslynWithNewRuleset: false diff --git a/eng/pipelines/templates/prepare-winget-manifest.yml b/eng/pipelines/templates/prepare-winget-manifest.yml index 386837a2749..26231ea2da3 100644 --- a/eng/pipelines/templates/prepare-winget-manifest.yml +++ b/eng/pipelines/templates/prepare-winget-manifest.yml @@ -57,9 +57,19 @@ steps: displayName: 🟣Set version ${{ parameters.version }} - pwsh: | - Write-Host "Installing Microsoft.WinGet.Client from PSGallery..." - Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -TrustRepository + $repoName = 'dotnet-public' + $repoUri = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json' + Write-Host "Ensuring PSResource repository '$repoName' is registered..." + $existingRepo = Get-PSResourceRepository -Name $repoName -ErrorAction SilentlyContinue + if ($null -eq $existingRepo) { + Register-PSResourceRepository -Name $repoName -Uri $repoUri -Trusted + } else { + Write-Host "PSResource repository '$repoName' is already registered. Skipping registration." + } + + Write-Host "Installing Microsoft.WinGet.Client from $repoName feed..." + Install-PSResource -Name Microsoft.WinGet.Client -Repository $repoName -TrustRepository Write-Host "Microsoft.WinGet.Client installed. Listing installed version:" Get-Module -ListAvailable Microsoft.WinGet.Client | Select-Object Name, Version | Format-Table From fc2b397f319835d998976a8770c7afc6eaaecd31 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Thu, 26 Mar 2026 08:42:50 +1100 Subject: [PATCH 38/49] Make VerifyAspireCliVersionAsync resilient across branches (#15561) Read VersionPrefix dynamically from eng/Versions.props instead of hardcoding a specific version. For non-stabilized builds (all normal PR builds), also verify the commit SHA suffix for exact build identity. This replaces the hardcoded '13.2.0' check that was added for the stabilized 13.2.0 release build. Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Helpers/CliE2EAutomatorHelpers.cs | 26 ++++++---- .../Helpers/CliE2ETestHelpers.cs | 48 +++++++++++++++++++ 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs index de3bf127406..55e016d5ab4 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs @@ -147,23 +147,33 @@ internal static async Task SourceAspireCliEnvironmentAsync( } /// - /// Verifies the installed Aspire CLI version matches the expected version. + /// Verifies the installed Aspire CLI version matches the expected build. + /// Always checks the dynamic version prefix from eng/Versions.props. + /// For non-stabilized builds (all normal PR builds), also verifies the commit SHA suffix. /// -#pragma warning disable IDE0060 // commitSha is unused during stabilized builds — restore when merging back to main internal static async Task VerifyAspireCliVersionAsync( this Hex1bTerminalAutomator auto, string commitSha, SequenceCounter counter) -#pragma warning restore IDE0060 { + var versionPrefix = CliE2ETestHelpers.GetVersionPrefix(); + var isStabilized = CliE2ETestHelpers.IsStabilizedBuild(); + await auto.TypeAsync("aspire --version"); await auto.EnterAsync(); - // When the build is stabilized (StabilizePackageVersion=true), the CLI version - // is just "13.2.0" with no commit SHA suffix. When not stabilized, it includes - // the SHA (e.g., "13.2.0-preview.1.g"). In both cases, "13.2.0" is present. - // TODO: This change should be reverted on the integration to the main branch. - await auto.WaitUntilTextAsync("13.2.0", timeout: TimeSpan.FromSeconds(10)); + // Always verify the version prefix matches the branch's version (e.g., "13.3.0"). + await auto.WaitUntilTextAsync(versionPrefix, timeout: TimeSpan.FromSeconds(10)); + + // For non-stabilized builds (all PR CI builds), also verify the commit SHA suffix + // to uniquely identify the exact build. Stabilized builds (official releases only) + // produce versions without SHA suffixes, so we skip this check. + if (!isStabilized && commitSha.Length == 40) + { + var shortCommitSha = commitSha[..8]; + var expectedVersionSuffix = $"g{shortCommitSha}"; + await auto.WaitUntilTextAsync(expectedVersionSuffix, timeout: TimeSpan.FromSeconds(10)); + } await auto.WaitForSuccessPromptAsync(counter); } diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs index ed41c1a899b..2937fec507c 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.CompilerServices; +using System.Xml.Linq; using Aspire.Cli.Tests.Utils; using Hex1b; using Xunit; @@ -309,4 +310,51 @@ internal static string ToContainerPath(string hostPath, TemporaryWorkspace works var relativePath = Path.GetRelativePath(workspace.WorkspaceRoot.FullName, hostPath); return $"/workspace/{workspace.WorkspaceRoot.Name}/" + relativePath.Replace('\\', '/'); } + + /// + /// Reads the VersionPrefix (e.g., "13.3.0") from eng/Versions.props by parsing + /// the MajorVersion, MinorVersion, and PatchVersion MSBuild properties. + /// + internal static string GetVersionPrefix() + { + var repoRoot = GetRepoRoot(); + var versionsPropsPath = Path.Combine(repoRoot, "eng", "Versions.props"); + + var doc = XDocument.Load(versionsPropsPath); + var ns = doc.Root?.Name.Namespace ?? XNamespace.None; + + string? GetProperty(string name) => + doc.Descendants(ns + name).FirstOrDefault()?.Value; + + var major = GetProperty("MajorVersion") + ?? throw new InvalidOperationException("MajorVersion not found in eng/Versions.props"); + var minor = GetProperty("MinorVersion") + ?? throw new InvalidOperationException("MinorVersion not found in eng/Versions.props"); + var patch = GetProperty("PatchVersion") + ?? throw new InvalidOperationException("PatchVersion not found in eng/Versions.props"); + + return $"{major}.{minor}.{patch}"; + } + + /// + /// Checks whether the build is stabilized (StabilizePackageVersion=true in eng/Versions.props). + /// Stabilized builds produce version strings without commit SHA suffixes (e.g., "13.2.0" instead + /// of "13.2.0-preview.1.25175.1+g{sha}"). This is only true for official release builds, + /// never for normal PR CI builds. + /// + internal static bool IsStabilizedBuild() + { + var repoRoot = GetRepoRoot(); + var versionsPropsPath = Path.Combine(repoRoot, "eng", "Versions.props"); + + var doc = XDocument.Load(versionsPropsPath); + var ns = doc.Root?.Name.Namespace ?? XNamespace.None; + + // The default value in Versions.props uses a Condition to default to "false", + // so we read the element's text directly. + var stabilize = doc.Descendants(ns + "StabilizePackageVersion") + .FirstOrDefault()?.Value; + + return string.Equals(stabilize, "true", StringComparison.OrdinalIgnoreCase); + } } From abe9990b5b8afe976a0bbc30c158e5ac14bcb9ed Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 26 Mar 2026 07:07:02 +0800 Subject: [PATCH 39/49] [release/13.2] Fix installing playwright-cli with aspire agent init on Windows (#15559) * Backport NpmRunner and SigstoreNpmProvenanceChecker changes from mad-skills * Clean up empty .playwright directory after skill installation * Add missing IsAvailable property to test INpmRunner implementations --- .../Agents/Playwright/PlaywrightCliRunner.cs | 23 ++ src/Aspire.Cli/Npm/INpmRunner.cs | 15 + src/Aspire.Cli/Npm/NpmRunner.cs | 111 ++++++-- .../Npm/SigstoreNpmProvenanceChecker.cs | 269 ++++++++++++++++-- .../Agents/PlaywrightCliInstallerTests.cs | 2 + .../SigstoreNpmProvenanceCheckerTests.cs | 121 ++++++++ tests/Aspire.Cli.Tests/Npm/NpmRunnerTests.cs | 129 +++++++++ .../TestServices/FakePlaywrightServices.cs | 2 + 8 files changed, 621 insertions(+), 51 deletions(-) create mode 100644 tests/Aspire.Cli.Tests/Npm/NpmRunnerTests.cs diff --git a/src/Aspire.Cli/Agents/Playwright/PlaywrightCliRunner.cs b/src/Aspire.Cli/Agents/Playwright/PlaywrightCliRunner.cs index b9abe4d6e5e..6ce7f52004c 100644 --- a/src/Aspire.Cli/Agents/Playwright/PlaywrightCliRunner.cs +++ b/src/Aspire.Cli/Agents/Playwright/PlaywrightCliRunner.cs @@ -125,5 +125,28 @@ public async Task InstallSkillsAsync(string workingDirectory, Cancellation logger.LogDebug(ex, "Failed to run playwright-cli install --skills"); return false; } + finally + { + // playwright-cli install --skills may leave behind an empty .playwright + // directory in the working directory. Clean it up if it exists and is empty. + CleanupEmptyPlaywrightDirectory(workingDirectory); + } + } + + private void CleanupEmptyPlaywrightDirectory(string workingDirectory) + { + try + { + var playwrightDir = Path.Combine(workingDirectory, ".playwright"); + if (Directory.Exists(playwrightDir) && Directory.GetFileSystemEntries(playwrightDir).Length == 0) + { + Directory.Delete(playwrightDir); + logger.LogDebug("Removed empty .playwright directory from {WorkingDirectory}", workingDirectory); + } + } + catch (IOException ex) + { + logger.LogDebug(ex, "Failed to clean up .playwright directory in {WorkingDirectory}", workingDirectory); + } } } diff --git a/src/Aspire.Cli/Npm/INpmRunner.cs b/src/Aspire.Cli/Npm/INpmRunner.cs index 7bd3eb27934..7580dd0e4a0 100644 --- a/src/Aspire.Cli/Npm/INpmRunner.cs +++ b/src/Aspire.Cli/Npm/INpmRunner.cs @@ -19,6 +19,16 @@ internal sealed class NpmPackageInfo /// Gets the SRI integrity hash (e.g., "sha512-...") for the package tarball. /// public required string Integrity { get; init; } + + /// + /// Formats a full npm package specifier (e.g., "@playwright/cli@0.1.1"). + /// + public static string FormatPackageSpecifier(string packageName, string version) => $"{packageName}@{version}"; + + /// + /// Formats a full npm package specifier (e.g., "@playwright/cli@0.1.1"). + /// + public static string FormatPackageSpecifier(string packageName, SemVersion version) => FormatPackageSpecifier(packageName, version.ToString()); } /// @@ -26,6 +36,11 @@ internal sealed class NpmPackageInfo /// internal interface INpmRunner { + /// + /// Gets a value indicating whether npm is available on the system PATH. + /// + bool IsAvailable { get; } + /// /// Resolves a package version and integrity hash from the npm registry. /// diff --git a/src/Aspire.Cli/Npm/NpmRunner.cs b/src/Aspire.Cli/Npm/NpmRunner.cs index 5f25a4ba85a..29791d43ab1 100644 --- a/src/Aspire.Cli/Npm/NpmRunner.cs +++ b/src/Aspire.Cli/Npm/NpmRunner.cs @@ -12,6 +12,18 @@ namespace Aspire.Cli.Npm; /// internal sealed class NpmRunner(ILogger logger) : INpmRunner { + /// + /// The public npm registry URL. Commands that resolve packages from the registry + /// pass this explicitly via --registry to avoid inheriting a project-level + /// .npmrc that may redirect to a private feed (e.g. Azure DevOps). + /// + private const string PublicRegistry = "https://registry.npmjs.org/"; + + private readonly Lazy _npmPath = new(() => PathLookupHelper.FindFullPathFromPath("npm")); + + /// + public bool IsAvailable => _npmPath.Value is not null; + /// public async Task ResolvePackageAsync(string packageName, string versionRange, CancellationToken cancellationToken) { @@ -21,6 +33,8 @@ internal sealed class NpmRunner(ILogger logger) : INpmRunner return null; } + logger.LogDebug("Resolving npm package {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, versionRange)); + // Use an isolated temp subdirectory so npm doesn't pick up .npmrc or // other config files from the shared temp root or the user's CWD. var tempDir = CreateIsolatedTempDirectory(); @@ -30,12 +44,13 @@ internal sealed class NpmRunner(ILogger logger) : INpmRunner // Resolve version: npm view @ version var versionOutput = await RunNpmCommandInDirectoryAsync( npmPath, - ["view", $"{packageName}@{versionRange}", "version"], + ["view", NpmPackageInfo.FormatPackageSpecifier(packageName, versionRange), "version", "--registry", PublicRegistry], tempDir, cancellationToken); if (versionOutput is null) { + logger.LogDebug("Failed to resolve version for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, versionRange)); return null; } @@ -49,16 +64,18 @@ internal sealed class NpmRunner(ILogger logger) : INpmRunner // Resolve integrity hash: npm view @ dist.integrity var integrityOutput = await RunNpmCommandInDirectoryAsync( npmPath, - ["view", $"{packageName}@{version}", "dist.integrity"], + ["view", NpmPackageInfo.FormatPackageSpecifier(packageName, version), "dist.integrity", "--registry", PublicRegistry], tempDir, cancellationToken); if (string.IsNullOrWhiteSpace(integrityOutput)) { - logger.LogDebug("Could not resolve integrity hash for {Package}@{Version}", packageName, version); + logger.LogDebug("Could not resolve integrity hash for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return null; } + logger.LogDebug("Resolved {PackageSpecifier} with integrity {Integrity}", NpmPackageInfo.FormatPackageSpecifier(packageName, version), integrityOutput.Trim()); + return new NpmPackageInfo { Version = version, @@ -80,14 +97,17 @@ internal sealed class NpmRunner(ILogger logger) : INpmRunner return null; } + logger.LogDebug("Packing npm package {PackageSpecifier} to {OutputDirectory}", NpmPackageInfo.FormatPackageSpecifier(packageName, version), outputDirectory); + var output = await RunNpmCommandInDirectoryAsync( npmPath, - ["pack", $"{packageName}@{version}", "--pack-destination", outputDirectory], + ["pack", NpmPackageInfo.FormatPackageSpecifier(packageName, version), "--pack-destination", outputDirectory, "--registry", PublicRegistry], outputDirectory, cancellationToken); if (output is null) { + logger.LogDebug("Failed to pack {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return null; } @@ -106,6 +126,8 @@ internal sealed class NpmRunner(ILogger logger) : INpmRunner return null; } + logger.LogDebug("Packed {PackageSpecifier} to {TarballPath}", NpmPackageInfo.FormatPackageSpecifier(packageName, version), tarballPath); + return tarballPath; } @@ -118,6 +140,8 @@ public async Task AuditSignaturesAsync(string packageName, string version, return false; } + logger.LogDebug("Auditing npm signatures for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); + // npm audit signatures requires a project context (node_modules + package-lock.json). // For global tool installs there is no project, so we create a temporary one. // The package must be installed from the registry (not a local tarball) because @@ -136,13 +160,13 @@ await File.WriteAllTextAsync( // Install the package from the registry to get proper attestation metadata var installOutput = await RunNpmCommandInDirectoryAsync( npmPath, - ["install", $"{packageName}@{version}", "--ignore-scripts"], + ["install", NpmPackageInfo.FormatPackageSpecifier(packageName, version), "--ignore-scripts", "--registry", PublicRegistry], tempDir, cancellationToken); if (installOutput is null) { - logger.LogDebug("Failed to install {Package}@{Version} into temporary project for audit", packageName, version); + logger.LogDebug("Failed to install {PackageSpecifier} into temporary project for audit", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return false; } @@ -153,7 +177,14 @@ await File.WriteAllTextAsync( tempDir, cancellationToken); - return auditOutput is not null; + if (auditOutput is null) + { + logger.LogDebug("Signature audit failed for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); + return false; + } + + logger.LogDebug("Signature audit passed for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); + return true; } finally { @@ -170,6 +201,8 @@ public async Task InstallGlobalAsync(string tarballPath, CancellationToken return false; } + logger.LogDebug("Installing npm package globally from {TarballPath}", tarballPath); + // Use an isolated temp subdirectory so npm doesn't pick up .npmrc or // other config files from the shared temp root or the user's CWD. var tempDir = CreateIsolatedTempDirectory(); @@ -182,7 +215,14 @@ public async Task InstallGlobalAsync(string tarballPath, CancellationToken tempDir, cancellationToken); - return output is not null; + if (output is null) + { + logger.LogDebug("Failed to install npm package globally from {TarballPath}", tarballPath); + return false; + } + + logger.LogDebug("Successfully installed npm package globally from {TarballPath}", tarballPath); + return true; } finally { @@ -192,7 +232,7 @@ public async Task InstallGlobalAsync(string tarballPath, CancellationToken private string? FindNpmPath() { - var npmPath = PathLookupHelper.FindFullPathFromPath("npm"); + var npmPath = _npmPath.Value; if (npmPath is null) { logger.LogDebug("npm is not installed or not found in PATH"); @@ -223,6 +263,45 @@ private void CleanupTempDirectory(string tempDir) } } + /// + /// Creates a configured to run an npm command. + /// On Windows, .cmd files are invoked via cmd.exe /c for reliable stdout redirection. + /// + internal static ProcessStartInfo CreateNpmProcessStartInfo(string npmPath, string[] args, string workingDirectory) + { + var startInfo = new ProcessStartInfo + { + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + WorkingDirectory = workingDirectory + }; + + // On Windows, npm resolves to npm.cmd (a batch wrapper). Launching + // .cmd files via Process.Start with redirected stdout can produce empty + // output. Use cmd.exe /c to invoke the batch file reliably. + // Note: cmd.exe /c has special quote-stripping rules that are incompatible + // with ArgumentList (which individually quotes each argument). We must use + // the Arguments string property and wrap the entire command in an outer set + // of quotes so cmd.exe preserves interior quoting correctly. + if (OperatingSystem.IsWindows() && npmPath.EndsWith(".cmd", StringComparison.OrdinalIgnoreCase)) + { + startInfo.FileName = "cmd.exe"; + startInfo.Arguments = @$"/c """"{npmPath}"" {string.Join(" ", args.Select(a => @$"""{a}"""))}"""; + } + else + { + startInfo.FileName = npmPath; + foreach (var arg in args) + { + startInfo.ArgumentList.Add(arg); + } + } + + return startInfo; + } + private async Task RunNpmCommandInDirectoryAsync(string npmPath, string[] args, string workingDirectory, CancellationToken cancellationToken) { var argsString = string.Join(" ", args); @@ -230,19 +309,7 @@ private void CleanupTempDirectory(string tempDir) try { - var startInfo = new ProcessStartInfo(npmPath) - { - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true, - WorkingDirectory = workingDirectory - }; - - foreach (var arg in args) - { - startInfo.ArgumentList.Add(arg); - } + var startInfo = CreateNpmProcessStartInfo(npmPath, args, workingDirectory); using var process = new Process { StartInfo = startInfo }; process.Start(); diff --git a/src/Aspire.Cli/Npm/SigstoreNpmProvenanceChecker.cs b/src/Aspire.Cli/Npm/SigstoreNpmProvenanceChecker.cs index 8cf739342ff..ee239097f20 100644 --- a/src/Aspire.Cli/Npm/SigstoreNpmProvenanceChecker.cs +++ b/src/Aspire.Cli/Npm/SigstoreNpmProvenanceChecker.cs @@ -1,8 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Security.Cryptography.X509Certificates; using System.Text.Json; using System.Text.Json.Nodes; +using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; using Sigstore; @@ -29,9 +31,12 @@ public async Task VerifyProvenanceAsync( CancellationToken cancellationToken, string? sriIntegrity = null) { + logger.LogDebug("Verifying provenance for {PackageSpecifier} from {ExpectedSourceRepository}", NpmPackageInfo.FormatPackageSpecifier(packageName, version), expectedSourceRepository); + var json = await FetchAttestationJsonAsync(packageName, version, cancellationToken).ConfigureAwait(false); if (json is null) { + logger.LogDebug("Attestation fetch failed for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationFetchFailed }; } @@ -39,11 +44,13 @@ public async Task VerifyProvenanceAsync( var bundleJson = ExtractSlsaBundleJson(json, out var parseFailed); if (bundleJson is null) { + var outcome = parseFailed + ? ProvenanceVerificationOutcome.AttestationParseFailed + : ProvenanceVerificationOutcome.SlsaProvenanceNotFound; + logger.LogDebug("SLSA bundle extraction failed for {PackageSpecifier}: {Outcome}", NpmPackageInfo.FormatPackageSpecifier(packageName, version), outcome); return new ProvenanceVerificationResult { - Outcome = parseFailed - ? ProvenanceVerificationOutcome.AttestationParseFailed - : ProvenanceVerificationOutcome.SlsaProvenanceNotFound + Outcome = outcome }; } @@ -54,7 +61,7 @@ public async Task VerifyProvenanceAsync( } catch (Exception ex) { - logger.LogDebug(ex, "Failed to deserialize Sigstore bundle for {Package}@{Version}", packageName, version); + logger.LogDebug(ex, "Failed to deserialize Sigstore bundle for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationParseFailed }; } @@ -73,12 +80,17 @@ public async Task VerifyProvenanceAsync( var provenance = ExtractProvenanceFromResult(verificationResult!); if (provenance is null) { + logger.LogDebug("Failed to extract provenance data from verified result for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationParseFailed }; } - return VerifyProvenanceFields( + var result = VerifyProvenanceFields( provenance, expectedSourceRepository, expectedWorkflowPath, expectedBuildType, validateWorkflowRef); + + logger.LogDebug("Provenance verification for {PackageSpecifier} completed with outcome {Outcome}", NpmPackageInfo.FormatPackageSpecifier(packageName, version), result.Outcome); + + return result; } /// @@ -105,7 +117,7 @@ public async Task VerifyProvenanceAsync( } catch (HttpRequestException ex) { - logger.LogDebug(ex, "Failed to fetch attestations for {Package}@{Version}", packageName, version); + logger.LogDebug(ex, "Failed to fetch attestations for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return null; } } @@ -194,57 +206,256 @@ public async Task VerifyProvenanceAsync( } var verifier = new SigstoreVerifier(); + var identityPolicy = CertificateIdentity.ForGitHubActions(owner, repo); var policy = new VerificationPolicy { - CertificateIdentity = CertificateIdentity.ForGitHubActions(owner, repo) + CertificateIdentity = identityPolicy }; try { - bool success; - VerificationResult? result; - - if (sriIntegrity is not null && sriIntegrity.StartsWith("sha512-", StringComparison.OrdinalIgnoreCase)) + var (success, result) = await VerifyBundleWithPolicyAsync( + verifier, bundle, policy, sriIntegrity, cancellationToken).ConfigureAwait(false); + + // Workaround for Sigstore .NET library bug on Windows where ExtractSan() fails because + // .NET formats URI-type SANs as "URL=..." but the library checks for "URI". This will be + // fixed in Sigstore 0.5.0. See https://github.com/mitchdenny/sigstore-dotnet/issues/14 + // + // When the SAN extraction fails, we retry cryptographic verification without the + // CertificateIdentity policy, then manually verify the three identity checks that + // ForGitHubActions would have performed (SAN pattern, OIDC issuer, SourceRepositoryUri) + // by reading the Fulcio certificate extensions directly from the bundle. This is safe + // because: + // + // 1. Full cryptographic verification still occurs: the Fulcio certificate chain is + // validated against the Sigstore TUF trust root, Signed Certificate Timestamps are + // checked, Rekor transparency log inclusion is verified, and the artifact signature + // (ECDSA over the DSSE envelope) is validated. An attacker cannot forge a bundle + // without Fulcio issuing them a certificate, which requires a valid OIDC token. + // + // 2. We manually verify the OIDC issuer from the Fulcio certificate extension + // (OID 1.3.6.1.4.1.57264.1.8), confirming the certificate was issued after + // authenticating with GitHub Actions' OIDC provider. These extensions are parsed + // from raw DER bytes (not the platform-dependent Format() method), so they work + // correctly on all platforms. + // + // 3. We manually verify the SourceRepositoryUri from the Fulcio certificate extension + // (OID 1.3.6.1.4.1.57264.1.12), confirming the signing identity is bound to the + // expected GitHub repository. This is the same check that ForGitHubActions performs + // via CertificateExtensionPolicy. + // + // 4. We manually verify the SAN matches the expected pattern for the GitHub repository. + // The SAN is extracted using a platform-independent method that handles both the + // "URI:" format (Linux/OpenSSL) and "URL=" format (Windows/CryptoAPI). + // + // 5. After this method returns, VerifyProvenanceFields() performs additional + // defense-in-depth checks on the SLSA predicate fields (source repository, workflow + // path, build type, workflow ref) from the DSSE payload, which was signature-verified + // in step 1. + // + // Once the upstream bug is fixed in Sigstore 0.5.0 and we upgrade, this retry logic and + // the VerifyCertificateIdentityFromBundle/ExtractSubjectAlternativeNamePortable helpers + // can be removed — the initial VerifyBundleWithPolicyAsync call with CertificateIdentity + // will succeed on all platforms. + if (!success + && result?.FailureReason is not null + && result.FailureReason.Contains("Subject Alternative Name", StringComparison.OrdinalIgnoreCase)) { - var hashBase64 = sriIntegrity["sha512-".Length..]; - var digestBytes = Convert.FromBase64String(hashBase64); + logger.LogDebug( + "Retrying Sigstore verification without CertificateIdentity due to known SAN extraction bug " + + "(https://github.com/mitchdenny/sigstore-dotnet/issues/14) for {PackageSpecifier}", + NpmPackageInfo.FormatPackageSpecifier(packageName, version)); - (success, result) = await verifier.TryVerifyDigestAsync( - digestBytes, HashAlgorithmType.Sha512, bundle, policy, cancellationToken).ConfigureAwait(false); - } - else - { - if (bundle.DsseEnvelope is null) + var fallbackPolicy = new VerificationPolicy(); + (success, result) = await VerifyBundleWithPolicyAsync( + verifier, bundle, fallbackPolicy, sriIntegrity, cancellationToken).ConfigureAwait(false); + + if (success) { - logger.LogDebug("No DSSE envelope found in bundle for {Package}@{Version}", packageName, version); - return (new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.PayloadDecodeFailed }, null); + var identityFailure = VerifyCertificateIdentityFromBundle(bundle, identityPolicy, packageName, version); + if (identityFailure is not null) + { + return (identityFailure, null); + } } - - (success, result) = await verifier.TryVerifyAsync( - bundle.DsseEnvelope.Payload, bundle, policy, cancellationToken).ConfigureAwait(false); } if (!success) { logger.LogWarning( - "Sigstore verification failed for {Package}@{Version}: {FailureReason}", - packageName, version, result?.FailureReason); + "Sigstore verification failed for {PackageSpecifier}: {FailureReason}", + NpmPackageInfo.FormatPackageSpecifier(packageName, version), result?.FailureReason); return (new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationParseFailed }, null); } logger.LogDebug( - "Sigstore verification passed for {Package}@{Version}. Signed by: {Signer}", - packageName, version, result?.SignerIdentity?.SubjectAlternativeName); + "Sigstore verification passed for {PackageSpecifier}. Signed by: {Signer}", + NpmPackageInfo.FormatPackageSpecifier(packageName, version), result?.SignerIdentity?.SubjectAlternativeName); return (null, result); } catch (Exception ex) { - logger.LogWarning(ex, "Sigstore verification threw an exception for {Package}@{Version}", packageName, version); + logger.LogWarning(ex, "Sigstore verification threw an exception for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); return (new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationParseFailed }, null); } } + /// + /// Dispatches bundle verification to the appropriate Sigstore verifier method + /// based on whether an SRI integrity digest is available. + /// + private static async Task<(bool Success, VerificationResult? Result)> VerifyBundleWithPolicyAsync( + SigstoreVerifier verifier, + SigstoreBundle bundle, + VerificationPolicy policy, + string? sriIntegrity, + CancellationToken cancellationToken) + { + if (sriIntegrity is not null && sriIntegrity.StartsWith("sha512-", StringComparison.OrdinalIgnoreCase)) + { + var hashBase64 = sriIntegrity["sha512-".Length..]; + var digestBytes = Convert.FromBase64String(hashBase64); + + return await verifier.TryVerifyDigestAsync( + digestBytes, HashAlgorithmType.Sha512, bundle, policy, cancellationToken).ConfigureAwait(false); + } + + // NOTE: When there is no SRI integrity digest and no DSSE envelope, this returns a generic + // VerificationResult with a failure reason string. The caller maps any verification failure + // to AttestationParseFailed, which differs from the previous behavior (PayloadDecodeFailed) + // that occurred when TryVerifyAsync was called with a null payload. + if (bundle.DsseEnvelope is null) + { + return (false, new VerificationResult { FailureReason = "No DSSE envelope found in bundle." }); + } + + return await verifier.TryVerifyAsync( + bundle.DsseEnvelope.Payload, bundle, policy, cancellationToken).ConfigureAwait(false); + } + + /// + /// Manually verifies the certificate identity checks that + /// would normally perform, by reading Fulcio certificate extensions directly from the bundle. + /// This is the workaround path used when the library's SAN extraction fails on Windows. + /// + private ProvenanceVerificationResult? VerifyCertificateIdentityFromBundle( + SigstoreBundle bundle, + CertificateIdentity expectedIdentity, + string packageName, + string version) + { + // Extract the leaf certificate from the bundle's verification material. + ReadOnlyMemory? certBytes = bundle.VerificationMaterial?.Certificate; + if (certBytes is null && bundle.VerificationMaterial?.CertificateChain is { Count: > 0 } chain) + { + certBytes = chain[0]; + } + + if (certBytes is not { Length: > 0 } leafCertBytes) + { + logger.LogWarning("No signing certificate found in bundle for {PackageSpecifier}", NpmPackageInfo.FormatPackageSpecifier(packageName, version)); + return new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationParseFailed }; + } + + using var cert = X509CertificateLoader.LoadCertificate(leafCertBytes.Span); + var extensions = FulcioCertificateExtensions.FromCertificate(cert); + + // Check OIDC issuer (OID 1.3.6.1.4.1.57264.1.8). + if (expectedIdentity.Issuer is not null) + { + if (extensions.Issuer is null || !string.Equals(extensions.Issuer, expectedIdentity.Issuer, StringComparison.Ordinal)) + { + logger.LogWarning( + "OIDC issuer mismatch for {PackageSpecifier}: expected '{Expected}', got '{Actual}'", + NpmPackageInfo.FormatPackageSpecifier(packageName, version), expectedIdentity.Issuer, extensions.Issuer); + return new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationParseFailed }; + } + } + + // Check SourceRepositoryUri extension (OID 1.3.6.1.4.1.57264.1.12). + if (expectedIdentity.Extensions?.SourceRepositoryUri is not null) + { + if (!string.Equals(extensions.SourceRepositoryUri, expectedIdentity.Extensions.SourceRepositoryUri, StringComparison.Ordinal)) + { + logger.LogWarning( + "SourceRepositoryUri mismatch for {PackageSpecifier}: expected '{Expected}', got '{Actual}'", + NpmPackageInfo.FormatPackageSpecifier(packageName, version), expectedIdentity.Extensions.SourceRepositoryUri, extensions.SourceRepositoryUri); + return new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.SourceRepositoryMismatch }; + } + } + + // Check SAN pattern using a platform-independent extraction that handles both "URI:" and "URL=". + if (expectedIdentity.SubjectAlternativeNamePattern is not null) + { + var san = ExtractSubjectAlternativeNamePortable(cert); + if (san is null || !Regex.IsMatch(san, expectedIdentity.SubjectAlternativeNamePattern)) + { + logger.LogWarning( + "SAN pattern mismatch for {PackageSpecifier}: expected pattern '{Pattern}', got '{Actual}'", + NpmPackageInfo.FormatPackageSpecifier(packageName, version), expectedIdentity.SubjectAlternativeNamePattern, san); + return new ProvenanceVerificationResult { Outcome = ProvenanceVerificationOutcome.AttestationParseFailed }; + } + } + + logger.LogDebug( + "Manual certificate identity verification passed for {PackageSpecifier} (issuer: {Issuer}, repo: {Repo})", + NpmPackageInfo.FormatPackageSpecifier(packageName, version), extensions.Issuer, extensions.SourceRepositoryUri); + + return null; + } + + /// + /// Extracts the URI-type Subject Alternative Name from a certificate in a platform-independent way. + /// Handles both "URI:" (Linux/OpenSSL) and "URL=" (Windows/CryptoAPI) formatting + /// produced by X509Extension.Format(bool). + /// + internal static string? ExtractSubjectAlternativeNamePortable(X509Certificate2 cert) + { + foreach (var ext in cert.Extensions) + { + if (ext.Oid?.Value != "2.5.29.17") + { + continue; + } + + var formatted = ext.Format(false); + var uri = ParseUriFromFormattedSan(formatted); + if (uri is not null) + { + return uri; + } + } + + return null; + } + + /// + /// Parses a URI value from the formatted string representation of a Subject Alternative Name extension. + /// Handles both "URI:" (Linux/OpenSSL) and "URL=" (Windows/CryptoAPI) formatting conventions. + /// + internal static string? ParseUriFromFormattedSan(string formattedSan) + { + foreach (var part in formattedSan.Split(',', StringSplitOptions.TrimEntries)) + { + // Linux/OpenSSL formats as "URI:https://..." + var uriIdx = part.IndexOf("URI:", StringComparison.OrdinalIgnoreCase); + if (uriIdx >= 0) + { + return part[(uriIdx + 4)..].Trim(); + } + + // Windows/CryptoAPI formats as "URL=https://..." + var urlIdx = part.IndexOf("URL=", StringComparison.OrdinalIgnoreCase); + if (urlIdx >= 0) + { + return part[(urlIdx + 4)..].Trim(); + } + } + + return null; + } + /// /// Extracts provenance data from a verified Sigstore result using the in-toto statement /// and Fulcio certificate extensions, avoiding manual JSON parsing of the DSSE payload. diff --git a/tests/Aspire.Cli.Tests/Agents/PlaywrightCliInstallerTests.cs b/tests/Aspire.Cli.Tests/Agents/PlaywrightCliInstallerTests.cs index c6d0ee519a4..12be67ebe90 100644 --- a/tests/Aspire.Cli.Tests/Agents/PlaywrightCliInstallerTests.cs +++ b/tests/Aspire.Cli.Tests/Agents/PlaywrightCliInstallerTests.cs @@ -540,6 +540,8 @@ public void SyncDirectory_RemovesExtraFilesInTarget() private sealed class TestNpmRunner : INpmRunner { + public bool IsAvailable => true; + public NpmPackageInfo? ResolveResult { get; set; } public string? PackResult { get; set; } public bool AuditResult { get; set; } = true; diff --git a/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs b/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs index a8399bdf029..0be6846b93a 100644 --- a/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs +++ b/tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs @@ -1045,4 +1045,125 @@ private static string BuildAttestationJsonWithBundle(string sourceRepository) } #endregion + + #region SAN Extraction Tests + + [Theory] + [InlineData("URI:https://github.com/nicolo-ribaudo/chokidar-3-to-2-fork/.github/workflows/publish-npm.yml@refs/heads/main")] + [InlineData("uri:https://github.com/nicolo-ribaudo/chokidar-3-to-2-fork/.github/workflows/publish-npm.yml@refs/heads/main")] + public void ParseUriFromFormattedSan_WithUriFormat_ExtractsUri(string formatted) + { + var result = SigstoreNpmProvenanceChecker.ParseUriFromFormattedSan(formatted); + Assert.Equal("https://github.com/nicolo-ribaudo/chokidar-3-to-2-fork/.github/workflows/publish-npm.yml@refs/heads/main", result); + } + + [Theory] + [InlineData("URL=https://github.com/nicolo-ribaudo/chokidar-3-to-2-fork/.github/workflows/publish-npm.yml@refs/heads/main")] + [InlineData("url=https://github.com/nicolo-ribaudo/chokidar-3-to-2-fork/.github/workflows/publish-npm.yml@refs/heads/main")] + public void ParseUriFromFormattedSan_WithUrlFormat_ExtractsUri(string formatted) + { + var result = SigstoreNpmProvenanceChecker.ParseUriFromFormattedSan(formatted); + Assert.Equal("https://github.com/nicolo-ribaudo/chokidar-3-to-2-fork/.github/workflows/publish-npm.yml@refs/heads/main", result); + } + + [Theory] + [InlineData("DNS:example.com")] + [InlineData("email:test@example.com")] + [InlineData("IP Address:192.168.1.1")] + public void ParseUriFromFormattedSan_WithNonUriFormat_ReturnsNull(string formatted) + { + var result = SigstoreNpmProvenanceChecker.ParseUriFromFormattedSan(formatted); + Assert.Null(result); + } + + [Fact] + public void ParseUriFromFormattedSan_WithMultipleEntries_ExtractsFirstUri() + { + var formatted = "DNS:example.com, URI:https://actions.github.com/workflow, email:test@test.com"; + var result = SigstoreNpmProvenanceChecker.ParseUriFromFormattedSan(formatted); + Assert.Equal("https://actions.github.com/workflow", result); + } + + [Fact] + public void ParseUriFromFormattedSan_WithWindowsMultipleEntries_ExtractsFirstUrl() + { + var formatted = "DNS Name=example.com, URL=https://actions.github.com/workflow, RFC822 Name=test@test.com"; + var result = SigstoreNpmProvenanceChecker.ParseUriFromFormattedSan(formatted); + Assert.Equal("https://actions.github.com/workflow", result); + } + + [Fact] + public void ParseUriFromFormattedSan_WithWhitespace_TrimsValue() + { + var formatted = "URI: https://actions.github.com/workflow "; + var result = SigstoreNpmProvenanceChecker.ParseUriFromFormattedSan(formatted); + Assert.Equal("https://actions.github.com/workflow", result); + } + + [Fact] + public void ExtractSubjectAlternativeNamePortable_WithUriSanCert_ExtractsSan() + { + var expectedUri = "https://github.com/test-org/test-repo/.github/workflows/publish.yml@refs/heads/main"; + using var cert = CreateCertificateWithUriSan(expectedUri); + var result = SigstoreNpmProvenanceChecker.ExtractSubjectAlternativeNamePortable(cert); + Assert.Equal(expectedUri, result); + } + + [Fact] + public void ExtractSubjectAlternativeNamePortable_WithCertWithoutSan_ReturnsNull() + { + using var cert = CreateSelfSignedCertWithoutSan(); + var result = SigstoreNpmProvenanceChecker.ExtractSubjectAlternativeNamePortable(cert); + Assert.Null(result); + } + + private static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateCertificateWithUriSan(string uri) + { + using var key = System.Security.Cryptography.RSA.Create(2048); + var request = new System.Security.Cryptography.X509Certificates.CertificateRequest( + "CN=Test", key, System.Security.Cryptography.HashAlgorithmName.SHA256, + System.Security.Cryptography.RSASignaturePadding.Pkcs1); + + // Build the SAN extension with a URI entry using raw ASN.1. + // SubjectAlternativeName is SEQUENCE { [6] IMPLICIT IA5String } + // Tag 0x86 = context-specific (bit 7) | constructed=0 | tag number 6 + var uriBytes = System.Text.Encoding.ASCII.GetBytes(uri); + var innerLength = uriBytes.Length; + var sanValueBytes = new byte[2 + innerLength + 2]; // SEQUENCE header + content + var offset = 0; + + // Write the uniformResourceIdentifier [6] IMPLICIT + sanValueBytes[offset++] = 0x86; // context tag 6 + sanValueBytes[offset++] = (byte)innerLength; + Array.Copy(uriBytes, 0, sanValueBytes, offset, innerLength); + offset += innerLength; + + // Wrap in SEQUENCE + var sequenceContent = sanValueBytes[..offset]; + var sequenceBytes = new byte[2 + sequenceContent.Length]; + sequenceBytes[0] = 0x30; // SEQUENCE tag + sequenceBytes[1] = (byte)sequenceContent.Length; + Array.Copy(sequenceContent, 0, sequenceBytes, 2, sequenceContent.Length); + + var sanExtension = new System.Security.Cryptography.X509Certificates.X509Extension( + new System.Security.Cryptography.Oid("2.5.29.17", "Subject Alternative Name"), + sequenceBytes, + critical: false); + + request.CertificateExtensions.Add(sanExtension); + + return request.CreateSelfSigned(DateTimeOffset.UtcNow.AddMinutes(-1), DateTimeOffset.UtcNow.AddHours(1)); + } + + private static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateSelfSignedCertWithoutSan() + { + using var key = System.Security.Cryptography.RSA.Create(2048); + var request = new System.Security.Cryptography.X509Certificates.CertificateRequest( + "CN=Test", key, System.Security.Cryptography.HashAlgorithmName.SHA256, + System.Security.Cryptography.RSASignaturePadding.Pkcs1); + + return request.CreateSelfSigned(DateTimeOffset.UtcNow.AddMinutes(-1), DateTimeOffset.UtcNow.AddHours(1)); + } + + #endregion } diff --git a/tests/Aspire.Cli.Tests/Npm/NpmRunnerTests.cs b/tests/Aspire.Cli.Tests/Npm/NpmRunnerTests.cs new file mode 100644 index 00000000000..bec74bc0e8f --- /dev/null +++ b/tests/Aspire.Cli.Tests/Npm/NpmRunnerTests.cs @@ -0,0 +1,129 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +using Aspire.Cli.Npm; + +namespace Aspire.Cli.Tests.Npm; + +public class NpmRunnerTests +{ + [Fact] + public void CreateNpmProcessStartInfo_SetsCommonProperties() + { + var startInfo = NpmRunner.CreateNpmProcessStartInfo("/usr/bin/npm", ["view", "express", "version"], "/tmp/workdir"); + + Assert.True(startInfo.RedirectStandardOutput); + Assert.True(startInfo.RedirectStandardError); + Assert.False(startInfo.UseShellExecute); + Assert.True(startInfo.CreateNoWindow); + Assert.Equal("/tmp/workdir", startInfo.WorkingDirectory); + } + + [Fact] + public void CreateNpmProcessStartInfo_OnWindows_WithCmdExtension_UsesCmdExe() + { + Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Windows-only test."); + + var startInfo = NpmRunner.CreateNpmProcessStartInfo( + @"C:\Program Files\nodejs\npm.cmd", + ["view", "@playwright/cli@0.1.1", "version", "--registry", "https://registry.npmjs.org/"], + @"C:\temp\workdir"); + + Assert.Equal("cmd.exe", startInfo.FileName); + Assert.Empty(startInfo.ArgumentList); + Assert.Contains("npm.cmd", startInfo.Arguments); + Assert.Contains("view", startInfo.Arguments); + Assert.Contains("@playwright/cli@0.1.1", startInfo.Arguments); + Assert.Contains("version", startInfo.Arguments); + Assert.Contains("--registry", startInfo.Arguments); + Assert.StartsWith("/c ", startInfo.Arguments); + Assert.Equal(@"C:\temp\workdir", startInfo.WorkingDirectory); + } + + [Fact] + public void CreateNpmProcessStartInfo_OnWindows_WithCmdExtension_WrapsInOuterQuotes() + { + Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Windows-only test."); + + var startInfo = NpmRunner.CreateNpmProcessStartInfo( + @"C:\Program Files\nodejs\npm.cmd", + ["view", "express", "version"], + @"C:\temp"); + + // cmd.exe /c requires outer quotes wrapping the entire command: + // /c ""C:\Program Files\nodejs\npm.cmd" "view" "express" "version"" + var args = startInfo.Arguments; + Assert.StartsWith(@"/c """, args); + Assert.EndsWith(@"""", args); + } + + [Fact] + public void CreateNpmProcessStartInfo_OnWindows_WithExeExtension_DoesNotUseCmdExe() + { + Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Windows-only test."); + + var startInfo = NpmRunner.CreateNpmProcessStartInfo( + @"C:\Program Files\nodejs\npm.exe", + ["view", "express", "version"], + @"C:\temp"); + + Assert.Equal(@"C:\Program Files\nodejs\npm.exe", startInfo.FileName); + Assert.Equal(["view", "express", "version"], startInfo.ArgumentList); + Assert.Empty(startInfo.Arguments); + } + + [Fact] + public void CreateNpmProcessStartInfo_OnNonWindows_UsesDirectInvocation() + { + Assert.SkipUnless(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Non-Windows-only test."); + + var startInfo = NpmRunner.CreateNpmProcessStartInfo( + "/usr/local/bin/npm", + ["view", "@playwright/cli@0.1.1", "version"], + "/tmp/workdir"); + + Assert.Equal("/usr/local/bin/npm", startInfo.FileName); + Assert.Equal(["view", "@playwright/cli@0.1.1", "version"], startInfo.ArgumentList); + Assert.Empty(startInfo.Arguments); + } + + [Fact] + public void CreateNpmProcessStartInfo_OnNonWindows_CmdExtensionIsIgnored() + { + Assert.SkipUnless(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Non-Windows-only test."); + + // On non-Windows, even a .cmd path is invoked directly (not via cmd.exe). + var startInfo = NpmRunner.CreateNpmProcessStartInfo( + "/usr/local/bin/npm.cmd", + ["view", "express", "version"], + "/tmp"); + + Assert.Equal("/usr/local/bin/npm.cmd", startInfo.FileName); + Assert.Equal(["view", "express", "version"], startInfo.ArgumentList); + Assert.Empty(startInfo.Arguments); + } + + [Fact] + public void CreateNpmProcessStartInfo_WithEmptyArgs_OnNonWindows_ProducesValidStartInfo() + { + Assert.SkipUnless(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Non-Windows-only test."); + + var startInfo = NpmRunner.CreateNpmProcessStartInfo("/usr/bin/npm", [], "/tmp"); + + Assert.Equal("/usr/bin/npm", startInfo.FileName); + Assert.Empty(startInfo.ArgumentList); + } + + [Fact] + public void CreateNpmProcessStartInfo_WithEmptyArgs_OnWindows_ProducesValidStartInfo() + { + Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Windows-only test."); + + var startInfo = NpmRunner.CreateNpmProcessStartInfo(@"C:\Program Files\nodejs\npm.cmd", [], @"C:\temp"); + + Assert.Equal("cmd.exe", startInfo.FileName); + Assert.Contains("npm.cmd", startInfo.Arguments); + Assert.Equal(@"C:\temp", startInfo.WorkingDirectory); + } +} diff --git a/tests/Aspire.Cli.Tests/TestServices/FakePlaywrightServices.cs b/tests/Aspire.Cli.Tests/TestServices/FakePlaywrightServices.cs index 8990e6ca8e9..9e86283fb49 100644 --- a/tests/Aspire.Cli.Tests/TestServices/FakePlaywrightServices.cs +++ b/tests/Aspire.Cli.Tests/TestServices/FakePlaywrightServices.cs @@ -12,6 +12,8 @@ namespace Aspire.Cli.Tests.TestServices; /// internal sealed class FakeNpmRunner : INpmRunner { + public bool IsAvailable => true; + public Task ResolvePackageAsync(string packageName, string versionRange, CancellationToken cancellationToken) => Task.FromResult(null); From 38f1283960739b302e467f0958172763a70ea76b Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Fri, 27 Mar 2026 04:26:41 +1100 Subject: [PATCH 40/49] [release/13.2] Handle brownfield TypeScript aspire init (#15123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Handle brownfield TypeScript aspire init Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use local tsx and semver-safe dependency merges Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Pre-add JavaScript hosting for brownfield init Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Incorporate release/13.2 ESLint and tsconfig.apphost.json updates - Update ts-starter template package.json build/watch scripts to use tsconfig.apphost.json - Add eslint.config.mjs scaffolding, ESLint deps, and engines constraint to CreatePackageJson - Add aspire:lint script to brownfield scaffolding - Update dependency versions to match release/13.2 baseline - Update test assertions for new dependency versions and eslint Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add CLI-side package.json merge for brownfield safety When aspire init is run on an existing JS/TS codebase, the scaffold RPC server returns package.json content that may not include brownfield merge logic (depending on the server package version loaded). This adds a safety net in the CLI's ScaffoldingService that deep-merges the scaffold output with the existing package.json on disk. The merge preserves all existing properties (name, version, scripts, dependencies) and only adds new properties from the scaffold. For nested objects like scripts and dependencies, existing values are never overwritten — only missing entries are added. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Extract PackageJsonMerger with smart script conflict handling Extract the package.json merge logic from ScaffoldingService into a dedicated PackageJsonMerger class with conflict-aware script handling. When scaffold scripts conflict with existing user scripts, they are added under the aspire: namespace prefix (a standard npm convention). For aspire:X scripts with no non-prefixed X equivalent, a convenience alias is added (e.g. "start": "npm run aspire:start"). This ensures all Aspire scripts are always present in the merged output regardless of whether existing scripts use the same names, and works correctly with both the updated server (aspire: prefixed) and stale server (non-prefixed) package versions. Also updates ts-starter template to consistently use aspire: prefixed scripts as canonical names with non-prefixed convenience aliases. Includes 14 unit tests covering conflicts, aliases, dependencies, edge cases, idempotency, and both stale/updated server scenarios. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add semver-aware dependency merging via shared NpmVersionHelper - Create src/Shared/NpmVersionHelper.cs with TryParseNpmVersion and ShouldUpgrade methods, file-linked into both Aspire.Cli and Aspire.Hosting.CodeGeneration.TypeScript - Update PackageJsonMerger.MergeDependencySection to upgrade existing deps when scaffold version is strictly newer (semver comparison) - Unparseable ranges (||, workspace:*, file:, link:) are preserved - Refactor TypeScriptLanguageSupport to use shared helper, removing ~50 lines of duplicated private methods - Add 6 new unit tests for semver-aware merging scenarios - Update 2 existing tests to reflect new upgrade-when-newer behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Harden PackageJsonMerger and deduplicate E2E helpers - Add type guards (JsonValue + TryGetValue) before GetValue() in MergeScripts and MergeDependencySection to prevent InvalidOperationException on non-string JSON values - Bump merge failure log level from Debug to Warning for visibility - Extract PrepareLocalChannel helper from TypeScriptPolyglotTests and TypeScriptStarterTemplateTests into shared CliE2ETestHelpers - Add 8 new robustness tests: non-string scripts, non-string deps, array dep section, JSON root as array, *, latest, pre-release version comparison Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add explicit engines.node overwrite and array property guard - Add MergeEngines() that overwrites engines.node with the scaffold's required Node version constraint (needed for ESLint 10 compatibility). Other engines sub-keys (e.g., npm) are preserved from existing. - Add guard in MergeObjects that throws InvalidOperationException if the scaffold template contains an array property — ensures developers add explicit merge logic rather than silently dropping data via DeepMerge. - Let InvalidOperationException propagate through the outer catch (it indicates a programming error, not a runtime merge failure). - Use 'as JsonObject' instead of .AsObject() to safely handle non-object JSON roots without throwing. - Add 4 new tests: engines overwrite, other keys preserved, engines added when missing, array property throws. - Update PreservesNonScriptProperties test for new engines behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix unicode escape in engines.node constraint on server side TypeScriptLanguageSupport used default JsonSerializerOptions which encodes >= as \u003E=. Add UnsafeRelaxedJsonEscaping (same as PackageJsonMerger) so the engines.node value is written as literal >=24 in the generated package.json. Add assertion to verify no unicode escapes appear in the raw scaffold output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review findings: internal visibility, private:true, engines for brownfield, LoadExisting hardening - Revert TypeScriptLanguageSupport from public to internal - Add private:true to greenfield scaffold output - Move engines.node outside greenfield-only block so brownfield also gets it - Harden LoadExistingPackageJson with try-catch for malformed JSON - Fix duplicate XML doc in TypeScriptStarterTemplateTests - Add brownfield engines.node and private assertions to tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address James' review: indent, logger, JSON tolerance, split try/catch, log style - Explicitly set 2-space indent (npm standard) with explanatory comment - Make logger non-nullable; tests use NullLogger.Instance - Add JsonCommentHandling.Skip + AllowTrailingCommas for real-world package.json - Split Merge into parse phase and merge phase with separate try/catch blocks - End log messages with periods (style convention) - Add test for package.json with comments and trailing commas Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix array property merge crash for brownfield npm init The PackageJsonMerger threw InvalidOperationException when encountering array properties like 'keywords' in the existing package.json. These arrays get echoed through the server-side scaffold and both sides have them during merge. Instead of throwing, preserve the existing array (existing-wins semantics) and add scaffold-only arrays. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address remaining review feedback: migration, double-merge, EnsureObject logging - Add RuntimeSpec.MigrationFiles and auto-create tsconfig.apphost.json on first run for existing 13.2.0 projects (fixes tsconfig breaking change) - Remove LoadExistingPackageJson; scaffold now produces Aspire-only content so CLI-side PackageJsonMerger handles all merging (fixes double-merge ordering dependency) - Thread ILogger through PackageJsonMerger internals; EnsureObject now logs a warning when replacing non-object values (fixes silent data loss) - Add comprehensive tests for all three fixes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review nits: non-nullable EnsureObject logger, GuestRuntime test helper - Make EnsureObject logger parameter non-nullable (consistent with Merge) - Add CreateRuntime helper to GuestRuntimeTests with ITestOutputHelper logging for better debuggability on test failures - Replace all NullLogger.Instance usages with the test logger Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Aspire.Cli/Aspire.Cli.csproj | 1 + src/Aspire.Cli/Projects/GuestRuntime.cs | 24 + .../Scaffolding/PackageJsonMerger.cs | 329 ++++ .../Scaffolding/ScaffoldingService.cs | 39 +- ...mplateFactory.TypeScriptStarterTemplate.cs | 4 +- .../Templates/ts-starter/package.json | 16 +- .../ts-starter/tsconfig.apphost.json | 15 + ...e.Hosting.CodeGeneration.TypeScript.csproj | 5 + .../TypeScriptLanguageSupport.cs | 181 ++- src/Aspire.TypeSystem/RuntimeSpec.cs | 7 + src/Shared/NpmVersionHelper.cs | 77 + .../Helpers/CliE2ETestHelpers.cs | 80 + .../TypeScriptPolyglotTests.cs | 146 ++ .../TypeScriptStarterTemplateTests.cs | 67 +- .../Commands/NewCommandTests.cs | 2 +- .../Projects/GuestRuntimeTests.cs | 176 +- .../Scaffolding/PackageJsonMergerTests.cs | 1439 +++++++++++++++++ .../TypeScriptLanguageSupportTests.cs | 220 +++ 18 files changed, 2735 insertions(+), 93 deletions(-) create mode 100644 src/Aspire.Cli/Scaffolding/PackageJsonMerger.cs create mode 100644 src/Aspire.Cli/Templating/Templates/ts-starter/tsconfig.apphost.json create mode 100644 src/Shared/NpmVersionHelper.cs create mode 100644 tests/Aspire.Cli.Tests/Scaffolding/PackageJsonMergerTests.cs create mode 100644 tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/TypeScriptLanguageSupportTests.cs diff --git a/src/Aspire.Cli/Aspire.Cli.csproj b/src/Aspire.Cli/Aspire.Cli.csproj index 7eca03b7b3a..2efc1e9bf9f 100644 --- a/src/Aspire.Cli/Aspire.Cli.csproj +++ b/src/Aspire.Cli/Aspire.Cli.csproj @@ -125,6 +125,7 @@ + diff --git a/src/Aspire.Cli/Projects/GuestRuntime.cs b/src/Aspire.Cli/Projects/GuestRuntime.cs index 8038acf25e6..497ffd3a8f8 100644 --- a/src/Aspire.Cli/Projects/GuestRuntime.cs +++ b/src/Aspire.Cli/Projects/GuestRuntime.cs @@ -139,6 +139,8 @@ public GuestRuntime(RuntimeSpec spec, ILogger logger, FileLoggerProvider? fileLo { var args = ReplacePlaceholders(commandSpec.Args, appHostFile, directory, additionalArgs); + await EnsureMigrationFilesExistAsync(directory, cancellationToken); + var mergedEnvironment = new Dictionary(environmentVariables); if (commandSpec.EnvironmentVariables is not null) { @@ -152,6 +154,28 @@ public GuestRuntime(RuntimeSpec spec, ILogger logger, FileLoggerProvider? fileLo return await launcher.LaunchAsync(commandSpec.Command, args, directory, mergedEnvironment, cancellationToken); } + /// + /// Creates any migration files that are required by the runtime but missing from the project directory. + /// This handles upgrade scenarios where a newer CLI introduces new required files. + /// + private async Task EnsureMigrationFilesExistAsync(DirectoryInfo directory, CancellationToken cancellationToken) + { + if (_spec.MigrationFiles is null or { Count: 0 }) + { + return; + } + + foreach (var (fileName, content) in _spec.MigrationFiles) + { + var filePath = Path.Combine(directory.FullName, fileName); + if (!File.Exists(filePath)) + { + _logger.LogInformation("Creating missing required file: {FileName}", fileName); + await File.WriteAllTextAsync(filePath, content, cancellationToken); + } + } + } + /// /// Creates the default process-based launcher for this runtime. /// diff --git a/src/Aspire.Cli/Scaffolding/PackageJsonMerger.cs b/src/Aspire.Cli/Scaffolding/PackageJsonMerger.cs new file mode 100644 index 00000000000..46545e78cc9 --- /dev/null +++ b/src/Aspire.Cli/Scaffolding/PackageJsonMerger.cs @@ -0,0 +1,329 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Nodes; +using Aspire.Shared; +using Microsoft.Extensions.Logging; + +namespace Aspire.Cli.Scaffolding; + +/// +/// Merges scaffold-generated package.json with an existing one on disk. +/// Handles script name conflicts by adding Aspire-specific scripts under the aspire: +/// namespace prefix, and creates convenience aliases for non-conflicting names. +/// +internal static class PackageJsonMerger +{ + private const string ScriptsKey = "scripts"; + private const string DependenciesKey = "dependencies"; + private const string DevDependenciesKey = "devDependencies"; + private const string EnginesKey = "engines"; + private const string EnginesNodeKey = "node"; + private const string AspirePrefix = "aspire:"; + + // package.json standard uses 2-space indentation. These options produce output + // consistent with npm init / npm install formatting conventions. + private static readonly JsonSerializerOptions s_jsonOptions = new() + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + IndentSize = 2 + }; + + private static readonly JsonDocumentOptions s_jsonDocumentOptions = new() + { + CommentHandling = JsonCommentHandling.Skip, + AllowTrailingCommas = true + }; + + /// + /// Merges scaffold-generated package.json content with existing content. + /// Preserves all existing properties and scripts. Scaffold scripts that conflict + /// with existing names are added under the aspire: prefix. Non-conflicting + /// aspire:X scripts get a convenience alias X pointing to npm run aspire:X. + /// + /// The merged package.json content as a JSON string. + internal static string Merge(string existingContent, string scaffoldContent, ILogger logger) + { + if (string.IsNullOrWhiteSpace(existingContent)) + { + return scaffoldContent; + } + + // Phase 1: Parse inputs. If either fails, return scaffold as-is. + JsonObject? existingJson; + JsonObject? scaffoldJson; + try + { + existingJson = JsonNode.Parse(existingContent, documentOptions: s_jsonDocumentOptions) as JsonObject; + scaffoldJson = JsonNode.Parse(scaffoldContent, documentOptions: s_jsonDocumentOptions) as JsonObject; + } + catch (Exception ex) + { + logger.LogWarning(ex, "Failed to parse package.json content, using scaffold output as-is."); + return scaffoldContent; + } + + if (existingJson is null || scaffoldJson is null) + { + return scaffoldContent; + } + + // Phase 2: Merge. If merge fails, return scaffold as-is. + try + { + MergeObjects(existingJson, scaffoldJson, logger); + return existingJson.ToJsonString(s_jsonOptions); + } + catch (Exception ex) + { + logger.LogWarning(ex, "Failed to merge package.json content, using scaffold output as-is."); + return scaffoldContent; + } + } + + /// + /// Merges all top-level properties from scaffold into existing. + /// Scripts get special conflict-aware handling, dependency sections use semver-aware merging, + /// and everything else uses deep merge. + /// + private static void MergeObjects(JsonObject existing, JsonObject scaffold, ILogger logger) + { + // Handle scripts separately with conflict-aware logic + var scaffoldScripts = scaffold[ScriptsKey]?.AsObject(); + if (scaffoldScripts is not null) + { + var existingScripts = EnsureObject(existing, ScriptsKey, logger); + MergeScripts(existingScripts, scaffoldScripts); + } + + // Handle dependency sections with semver-aware merging + MergeDependencySection(existing, scaffold, DependenciesKey, logger); + MergeDependencySection(existing, scaffold, DevDependenciesKey, logger); + + // Handle engines with overwrite semantics for "node" — since the user is running + // "aspire init", we enforce our Node version constraint (required for ESLint 10 + // and TypeScript tooling compatibility). Other engines sub-keys are preserved. + MergeEngines(existing, scaffold, logger); + + // Deep merge everything else (scalars, nested objects). + // Array properties (e.g., "keywords") are preserved from existing — the scaffold + // echoes the original arrays unchanged, so the existing value is always correct. + foreach (var (key, sourceValue) in scaffold) + { + if (key is ScriptsKey or DependenciesKey or DevDependenciesKey or EnginesKey || sourceValue is null) + { + continue; + } + + var targetValue = existing[key]; + + if (targetValue is null) + { + // Property only in scaffold — add it (including arrays from scaffold-only) + existing[key] = sourceValue.DeepClone(); + } + else if (targetValue is JsonObject targetObj && sourceValue is JsonObject sourceObj) + { + DeepMerge(targetObj, sourceObj); + } + // Arrays and scalar values in existing are preserved + } + } + + /// + /// Merges scaffold scripts into existing scripts with conflict-aware handling. + /// + /// + /// For each scaffold script: + /// + /// Already aspire: prefixed → always added/updated + /// Not prefixed, conflicts with existing → added as aspire:{name} + /// Not prefixed, no conflict → added with the original name + /// + /// After processing, for each aspire:X script where no non-prefixed X exists, + /// a convenience alias is added: "X": "npm run aspire:X". + /// + internal static void MergeScripts(JsonObject existingScripts, JsonObject scaffoldScripts) + { + foreach (var (name, value) in scaffoldScripts) + { + if (value is not JsonValue scriptValue || !scriptValue.TryGetValue(out var command)) + { + continue; + } + + if (name.StartsWith(AspirePrefix, StringComparison.Ordinal)) + { + // Already prefixed — always set it + existingScripts[name] = command; + } + else if (existingScripts[name] is not null) + { + // Conflict — add under aspire: prefix + existingScripts[$"{AspirePrefix}{name}"] = command; + } + else + { + // No conflict — add with original name + existingScripts[name] = command; + } + } + + // Add convenience aliases for aspire: scripts that have no non-prefixed equivalent + AddConvenienceAliases(existingScripts); + } + + /// + /// For each aspire:X script, if no script named X exists, + /// adds "X": "npm run aspire:X" as a convenience alias. + /// + private static void AddConvenienceAliases(JsonObject scripts) + { + // Collect aspire: keys first to avoid modifying during enumeration + var aspireScripts = new List<(string unprefixed, string prefixed)>(); + foreach (var (name, _) in scripts) + { + if (name.StartsWith(AspirePrefix, StringComparison.Ordinal)) + { + var unprefixed = name[AspirePrefix.Length..]; + if (unprefixed.Length > 0) + { + aspireScripts.Add((unprefixed, name)); + } + } + } + + foreach (var (unprefixed, prefixed) in aspireScripts) + { + if (scripts[unprefixed] is null) + { + scripts[unprefixed] = $"npm run {prefixed}"; + } + } + } + + /// + /// Merges a dependency section (e.g., "dependencies", "devDependencies") from scaffold into existing + /// using semver-aware comparison. New packages are added; existing packages are upgraded only when + /// the scaffold specifies a newer version. Unparseable version ranges (union ranges, workspace + /// references, etc.) are preserved as-is. + /// + private static void MergeDependencySection(JsonObject existing, JsonObject scaffold, string sectionName, ILogger logger) + { + var scaffoldDeps = scaffold[sectionName]?.AsObject(); + if (scaffoldDeps is null) + { + return; + } + + var existingDeps = EnsureObject(existing, sectionName, logger); + + foreach (var (packageName, versionNode) in scaffoldDeps) + { + if (versionNode is not JsonValue desiredValue || !desiredValue.TryGetValue(out var desiredVersion)) + { + continue; + } + + var existingVersionNode = existingDeps[packageName]; + if (existingVersionNode is null) + { + existingDeps[packageName] = desiredVersion; + } + else + { + if (existingVersionNode is JsonValue existingValue + && existingValue.TryGetValue(out var existingVersion) + && NpmVersionHelper.ShouldUpgrade(existingVersion, desiredVersion)) + { + existingDeps[packageName] = desiredVersion; + } + } + } + } + + /// + /// Merges the engines section from scaffold into existing. The engines.node + /// constraint is always overwritten by the scaffold's value because aspire init requires + /// specific Node.js versions for ESLint 10 and TypeScript tooling compatibility. Other + /// engines sub-keys (e.g., npm) are preserved from the existing package.json. + /// + private static void MergeEngines(JsonObject existing, JsonObject scaffold, ILogger logger) + { + var scaffoldEngines = scaffold[EnginesKey]?.AsObject(); + if (scaffoldEngines is null) + { + return; + } + + var existingEngines = EnsureObject(existing, EnginesKey, logger); + + foreach (var (key, value) in scaffoldEngines) + { + if (value is null) + { + continue; + } + + if (key == EnginesNodeKey) + { + // Always overwrite engines.node — Aspire requires specific Node versions + existingEngines[key] = value.DeepClone(); + } + else if (existingEngines[key] is null) + { + existingEngines[key] = value.DeepClone(); + } + // Other existing engine constraints are preserved + } + } + + /// + /// Deep merges properties from source into target. Existing target values are preserved. + /// For nested objects, recursively merges. Scalar values in target are never overwritten. + /// + internal static void DeepMerge(JsonObject target, JsonObject source) + { + foreach (var (key, sourceValue) in source) + { + if (sourceValue is null) + { + continue; + } + + var targetValue = target[key]; + + if (targetValue is null) + { + target[key] = sourceValue.DeepClone(); + } + else if (targetValue is JsonObject targetObj && sourceValue is JsonObject sourceObj) + { + DeepMerge(targetObj, sourceObj); + } + // Scalar values in target are preserved + } + } + + private static JsonObject EnsureObject(JsonObject parent, string propertyName, ILogger logger) + { + if (parent[propertyName] is JsonObject obj) + { + return obj; + } + + if (parent[propertyName] is not null) + { + logger.LogWarning( + "Replacing non-object '{PropertyName}' value with an empty object. The original value will be lost.", + propertyName); + } + + obj = new JsonObject(); + parent[propertyName] = obj; + return obj; + } +} diff --git a/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs b/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs index 9b8dffb1fd1..5756709dff0 100644 --- a/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs +++ b/src/Aspire.Cli/Scaffolding/ScaffoldingService.cs @@ -15,6 +15,9 @@ namespace Aspire.Cli.Scaffolding; /// internal sealed class ScaffoldingService : IScaffoldingService { + private const string PackageJsonFileName = "package.json"; + private const string JavaScriptHostingPackageName = "Aspire.Hosting.JavaScript"; + private readonly IAppHostServerProjectFactory _appHostServerProjectFactory; private readonly ILanguageDiscovery _languageDiscovery; private readonly IInteractionService _interactionService; @@ -51,6 +54,7 @@ private async Task ScaffoldGuestLanguageAsync(ScaffoldContext context, Can // Step 1: Resolve SDK and package strategy var sdkVersion = VersionHelper.GetDefaultSdkVersion(); var config = AspireConfigFile.LoadOrCreate(directory.FullName, sdkVersion); + PreAddJavaScriptHostingForBrownfieldTypeScript(config, directory, language, sdkVersion); // Include the code generation package for scaffolding and code gen var codeGenPackage = await _languageDiscovery.GetPackageForLanguageAsync(language.LanguageId, cancellationToken); @@ -94,7 +98,7 @@ private async Task ScaffoldGuestLanguageAsync(ScaffoldContext context, Can context.ProjectName, cancellationToken); - // Step 4: Write scaffold files to disk + // Step 4: Write scaffold files to disk, merging package.json with existing content foreach (var (fileName, content) in scaffoldFiles) { var filePath = Path.Combine(directory.FullName, fileName); @@ -103,7 +107,15 @@ private async Task ScaffoldGuestLanguageAsync(ScaffoldContext context, Can { Directory.CreateDirectory(fileDirectory); } - await File.WriteAllTextAsync(filePath, content, cancellationToken); + + var contentToWrite = content; + if (fileName.Equals(PackageJsonFileName, StringComparison.OrdinalIgnoreCase) && File.Exists(filePath)) + { + var existingContent = await File.ReadAllTextAsync(filePath, cancellationToken); + contentToWrite = PackageJsonMerger.Merge(existingContent, content, _logger); + } + + await File.WriteAllTextAsync(filePath, contentToWrite, cancellationToken); } _logger.LogDebug("Wrote {Count} scaffold files", scaffoldFiles.Count); @@ -208,4 +220,27 @@ private async Task GenerateCodeViaRpcAsync( _logger.LogDebug("Generated {Count} code files in {Path}", generatedFiles.Count, outputPath); } + + private static void PreAddJavaScriptHostingForBrownfieldTypeScript( + AspireConfigFile config, + DirectoryInfo directory, + LanguageInfo language, + string defaultSdkVersion) + { + if (!IsTypeScriptLanguage(language) || + !File.Exists(Path.Combine(directory.FullName, PackageJsonFileName)) || + config.Packages?.ContainsKey(JavaScriptHostingPackageName) == true) + { + return; + } + + config.AddOrUpdatePackage(JavaScriptHostingPackageName, config.GetEffectiveSdkVersion(defaultSdkVersion)); + } + + private static bool IsTypeScriptLanguage(LanguageInfo language) + { + return language.LanguageId.Value.Equals(KnownLanguageId.TypeScript, StringComparison.OrdinalIgnoreCase) || + language.LanguageId.Value.Equals(KnownLanguageId.TypeScriptAlias, StringComparison.OrdinalIgnoreCase); + } + } diff --git a/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs b/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs index f910e0c21e3..cdb6fe354c0 100644 --- a/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs +++ b/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs @@ -61,10 +61,10 @@ private async Task ApplyTypeScriptStarterTemplateAsync(CallbackT _logger.LogDebug("Copying embedded TypeScript starter template files to '{OutputPath}'.", outputPath); await CopyTemplateTreeToDiskAsync("ts-starter", outputPath, ApplyAllTokens, cancellationToken); - // Write channel to settings.json before restore so package resolution uses the selected channel. + // Write channel to aspire.config.json before restore so package resolution uses the selected channel. if (!string.IsNullOrEmpty(inputs.Channel)) { - var config = AspireJsonConfiguration.Load(outputPath); + var config = AspireConfigFile.Load(outputPath); if (config is not null) { config.Channel = inputs.Channel; diff --git a/src/Aspire.Cli/Templating/Templates/ts-starter/package.json b/src/Aspire.Cli/Templating/Templates/ts-starter/package.json index 7878cd35dbe..c64a43c21c9 100644 --- a/src/Aspire.Cli/Templating/Templates/ts-starter/package.json +++ b/src/Aspire.Cli/Templating/Templates/ts-starter/package.json @@ -3,12 +3,16 @@ "private": true, "type": "module", "scripts": { - "lint": "eslint apphost.ts", - "predev": "npm run lint", - "dev": "aspire run", - "prebuild": "npm run lint", - "build": "tsc", - "watch": "tsc --watch" + "aspire:lint": "eslint apphost.ts", + "aspire:start": "aspire run", + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:dev": "tsc --watch -p tsconfig.apphost.json", + "lint": "npm run aspire:lint", + "predev": "npm run aspire:lint", + "dev": "npm run aspire:start", + "prebuild": "npm run aspire:lint", + "build": "npm run aspire:build", + "watch": "npm run aspire:dev" }, "dependencies": { "vscode-jsonrpc": "^8.2.0" diff --git a/src/Aspire.Cli/Templating/Templates/ts-starter/tsconfig.apphost.json b/src/Aspire.Cli/Templating/Templates/ts-starter/tsconfig.apphost.json new file mode 100644 index 00000000000..dd679d553ce --- /dev/null +++ b/src/Aspire.Cli/Templating/Templates/ts-starter/tsconfig.apphost.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "outDir": "./dist/apphost", + "rootDir": "." + }, + "include": ["apphost.ts", ".modules/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/Aspire.Hosting.CodeGeneration.TypeScript.csproj b/src/Aspire.Hosting.CodeGeneration.TypeScript/Aspire.Hosting.CodeGeneration.TypeScript.csproj index 58e1b22094c..2a4cdb9b711 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/Aspire.Hosting.CodeGeneration.TypeScript.csproj +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/Aspire.Hosting.CodeGeneration.TypeScript.csproj @@ -24,6 +24,11 @@ + + + + + diff --git a/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs b/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs index 7858548d2d3..380cc05c88a 100644 --- a/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs +++ b/src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs @@ -1,6 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Text.Json; +using System.Text.Json.Nodes; +using Aspire.Shared; using Aspire.TypeSystem; namespace Aspire.Hosting.CodeGeneration.TypeScript; @@ -23,6 +26,36 @@ internal sealed class TypeScriptLanguageSupport : ILanguageSupport private const string CodeGenTarget = "TypeScript"; private const string LanguageDisplayName = "TypeScript (Node.js)"; + private const string AppHostFileName = "apphost.ts"; + private const string PackageJsonFileName = "package.json"; + private const string AppHostTsConfigFileName = "tsconfig.apphost.json"; + + /// + /// The default content for tsconfig.apphost.json, shared between scaffolding and migration. + /// + private const string AppHostTsConfigContent = """ + { + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "outDir": "./dist/apphost", + "rootDir": "." + }, + "include": ["apphost.ts", ".modules/**/*.ts"], + "exclude": ["node_modules"] + } + """; + + private static readonly JsonSerializerOptions s_jsonSerializerOptions = new() + { + WriteIndented = true, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; private static readonly string[] s_detectionPatterns = ["apphost.ts"]; /// @@ -34,7 +67,7 @@ public Dictionary Scaffold(ScaffoldRequest request) var files = new Dictionary(); // Create apphost.ts - files["apphost.ts"] = """ + files[AppHostFileName] = """ // Aspire TypeScript AppHost // For more information, see: https://aspire.dev @@ -49,39 +82,7 @@ public Dictionary Scaffold(ScaffoldRequest request) await builder.build().run(); """; - // Create package.json - // NOTE: The engines.node constraint must match ESLint 10's own requirement - // (^20.19.0 || ^22.13.0 || >=24) to avoid install/runtime failures on unsupported Node versions. - var packageName = request.ProjectName?.ToLowerInvariant() ?? "aspire-apphost"; - files["package.json"] = $$""" - { - "name": "{{packageName}}", - "private": true, - "type": "module", - "scripts": { - "lint": "eslint apphost.ts", - "predev": "npm run lint", - "dev": "aspire run", - "prebuild": "npm run lint", - "build": "tsc", - "watch": "tsc --watch" - }, - "dependencies": { - "vscode-jsonrpc": "^8.2.0" - }, - "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" - }, - "devDependencies": { - "@types/node": "^22.0.0", - "eslint": "^10.0.3", - "nodemon": "^3.1.14", - "tsx": "^4.21.0", - "typescript": "^5.9.3", - "typescript-eslint": "^8.57.1" - } - } - """; + files[PackageJsonFileName] = CreatePackageJson(request); // Create eslint.config.mjs for catching unawaited promises in apphost.ts files["eslint.config.mjs"] = """ @@ -105,24 +106,8 @@ public Dictionary Scaffold(ScaffoldRequest request) }); """; - // Create tsconfig.json for TypeScript configuration - files["tsconfig.json"] = """ - { - "compilerOptions": { - "target": "ES2022", - "module": "NodeNext", - "moduleResolution": "NodeNext", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, - "outDir": "./dist", - "rootDir": "." - }, - "include": ["apphost.ts", ".modules/**/*.ts"], - "exclude": ["node_modules"] - } - """; + // Create an apphost-specific tsconfig so existing brownfield TypeScript settings are preserved. + files[AppHostTsConfigFileName] = AppHostTsConfigContent; // Create apphost.run.json with random ports // Use PortSeed if provided (for testing), otherwise use random @@ -152,18 +137,95 @@ public Dictionary Scaffold(ScaffoldRequest request) return files; } + private static string CreatePackageJson(ScaffoldRequest request) + { + // Build scaffold output with only Aspire-desired content. We intentionally do NOT + // read the existing package.json here — the CLI-side PackageJsonMerger handles all + // combining with on-disk content. Including existing entries in the scaffold output + // would cause a double-merge where correctness depends on JsonObject iteration order. + var packageJson = new JsonObject(); + var packageJsonPath = Path.Combine(request.TargetPath, PackageJsonFileName); + + if (!File.Exists(packageJsonPath)) + { + // Greenfield: include root metadata so the scaffold output is a complete package.json. + var packageName = request.ProjectName?.ToLowerInvariant() ?? "aspire-apphost"; + packageJson["name"] = packageName; + packageJson["version"] = "1.0.0"; + packageJson["private"] = true; + packageJson["type"] = "module"; + } + + // NOTE: The engines.node constraint must match ESLint 10's own requirement + // (^20.19.0 || ^22.13.0 || >=24) to avoid install/runtime failures on unsupported Node versions. + // This is set for both greenfield and brownfield scenarios — the user is opting into Aspire + // which requires these Node versions. The CLI-side MergeEngines also enforces this during merge. + var engines = EnsureObject(packageJson, "engines"); + engines["node"] = "^20.19.0 || ^22.13.0 || >=24"; + + var scripts = EnsureObject(packageJson, "scripts"); + scripts["aspire:lint"] = "eslint apphost.ts"; + scripts["aspire:start"] = "aspire run"; + scripts["aspire:build"] = $"tsc -p {AppHostTsConfigFileName}"; + scripts["aspire:dev"] = $"tsc --watch -p {AppHostTsConfigFileName}"; + + EnsureDependency(packageJson, "dependencies", "vscode-jsonrpc", "^8.2.0"); + EnsureDependency(packageJson, "devDependencies", "@types/node", "^22.0.0"); + EnsureDependency(packageJson, "devDependencies", "eslint", "^10.0.3"); + EnsureDependency(packageJson, "devDependencies", "nodemon", "^3.1.14"); + EnsureDependency(packageJson, "devDependencies", "tsx", "^4.21.0"); + EnsureDependency(packageJson, "devDependencies", "typescript", "^5.9.3"); + EnsureDependency(packageJson, "devDependencies", "typescript-eslint", "^8.57.1"); + + return packageJson.ToJsonString(s_jsonSerializerOptions); + } + + private static void EnsureDependency(JsonObject packageJson, string sectionName, string packageName, string version) + { + var section = EnsureObject(packageJson, sectionName); + + var existingVersion = GetStringValue(section[packageName]); + if (existingVersion is null) + { + section[packageName] = version; + return; + } + + if (NpmVersionHelper.ShouldUpgrade(existingVersion, version)) + { + section[packageName] = version; + } + } + + private static JsonObject EnsureObject(JsonObject parent, string propertyName) + { + if (parent[propertyName] is JsonObject obj) + { + return obj; + } + + obj = new JsonObject(); + parent[propertyName] = obj; + return obj; + } + + private static string? GetStringValue(JsonNode? node) + { + return node is JsonValue value && value.TryGetValue(out var stringValue) ? stringValue : null; + } + /// public DetectionResult Detect(string directoryPath) { // Check for apphost.ts - var appHostPath = Path.Combine(directoryPath, "apphost.ts"); + var appHostPath = Path.Combine(directoryPath, AppHostFileName); if (!File.Exists(appHostPath)) { return DetectionResult.NotFound; } // Check for package.json (required for TypeScript/Node.js projects) - var packageJsonPath = Path.Combine(directoryPath, "package.json"); + var packageJsonPath = Path.Combine(directoryPath, PackageJsonFileName); if (!File.Exists(packageJsonPath)) { return DetectionResult.NotFound; @@ -172,7 +234,7 @@ public DetectionResult Detect(string directoryPath) // Note: .csproj precedence is handled by the CLI, not here. // Language support should only check for its own language markers. - return DetectionResult.Found(LanguageId, "apphost.ts"); + return DetectionResult.Found(LanguageId, AppHostFileName); } /// @@ -193,20 +255,25 @@ public RuntimeSpec GetRuntimeSpec() Execute = new CommandSpec { Command = "npx", - Args = ["tsx", "{appHostFile}"] + Args = ["--no-install", "tsx", "--tsconfig", AppHostTsConfigFileName, "{appHostFile}"] }, WatchExecute = new CommandSpec { Command = "npx", Args = [ + "--no-install", "nodemon", "--signal", "SIGTERM", "--watch", ".", "--ext", "ts", "--ignore", "node_modules/", "--ignore", ".modules/", - "--exec", "npx tsx {appHostFile}" + "--exec", $"npx --no-install tsx --tsconfig {AppHostTsConfigFileName} {{appHostFile}}" ] + }, + MigrationFiles = new Dictionary + { + [AppHostTsConfigFileName] = AppHostTsConfigContent } }; } diff --git a/src/Aspire.TypeSystem/RuntimeSpec.cs b/src/Aspire.TypeSystem/RuntimeSpec.cs index 50d0a2aee34..6fa90fa9995 100644 --- a/src/Aspire.TypeSystem/RuntimeSpec.cs +++ b/src/Aspire.TypeSystem/RuntimeSpec.cs @@ -54,6 +54,13 @@ public sealed class RuntimeSpec /// this capability. When null, the CLI always uses the default process-based launcher. /// public string? ExtensionLaunchCapability { get; init; } + + /// + /// Gets files that must exist in the project directory before execution. + /// If a file in this dictionary is missing, the CLI will create it with the provided content. + /// This supports upgrade scenarios where new runtime requirements are introduced. + /// + public Dictionary? MigrationFiles { get; init; } } /// diff --git a/src/Shared/NpmVersionHelper.cs b/src/Shared/NpmVersionHelper.cs new file mode 100644 index 00000000000..5e9ebd0012a --- /dev/null +++ b/src/Shared/NpmVersionHelper.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Semver; + +namespace Aspire.Shared; + +/// +/// Helpers for parsing and comparing npm-style version ranges. +/// +internal static class NpmVersionHelper +{ + /// + /// Determines whether the existing dependency version should be upgraded to the desired version. + /// Returns true when both versions are parseable and the desired version is newer. + /// + internal static bool ShouldUpgrade(string existingVersion, string desiredVersion) + { + return TryParseNpmVersion(existingVersion, out var existingSemVersion) + && TryParseNpmVersion(desiredVersion, out var desiredSemVersion) + && SemVersion.ComparePrecedence(existingSemVersion, desiredSemVersion) < 0; + } + + /// + /// Attempts to extract a comparable from an npm version range string. + /// Strips range operators (^, ~, >=, <=, >, <, =) + /// and parses the remaining version. Returns false for union ranges (||), + /// workspace references, file paths, and symlinks. + /// + internal static bool TryParseNpmVersion(string version, out SemVersion semVersion) + { + var normalizedVersion = version.Trim(); + if (normalizedVersion.Contains("||", StringComparison.Ordinal) || + normalizedVersion.StartsWith("workspace:", StringComparison.OrdinalIgnoreCase) || + normalizedVersion.StartsWith("file:", StringComparison.OrdinalIgnoreCase) || + normalizedVersion.StartsWith("link:", StringComparison.OrdinalIgnoreCase)) + { + semVersion = default!; + return false; + } + + while (normalizedVersion.Length > 0) + { + if (normalizedVersion.StartsWith(">=", StringComparison.Ordinal) || + normalizedVersion.StartsWith("<=", StringComparison.Ordinal)) + { + normalizedVersion = normalizedVersion[2..].TrimStart(); + continue; + } + + if (normalizedVersion[0] is '^' or '~' or '>' or '<' or '=') + { + normalizedVersion = normalizedVersion[1..].TrimStart(); + continue; + } + + break; + } + + if (SemVersion.TryParse(normalizedVersion, SemVersionStyles.Strict, out var strictVersion) && + strictVersion is not null) + { + semVersion = strictVersion; + return true; + } + + if (SemVersion.TryParse(normalizedVersion, SemVersionStyles.Any, out var anyVersion) && + anyVersion is not null) + { + semVersion = anyVersion; + return true; + } + + semVersion = default!; + return false; + } +} diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs index 2937fec507c..ea3e7f1e0a2 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; using System.Xml.Linq; using Aspire.Cli.Tests.Utils; using Hex1b; @@ -357,4 +358,83 @@ internal static bool IsStabilizedBuild() return string.Equals(stabilize, "true", StringComparison.OrdinalIgnoreCase); } + + /// + /// Prepares a local NuGet package channel for source-build E2E tests. + /// Copies packed Aspire.*.nupkg files to a workspace-local directory and extracts the SDK version. + /// Returns null for non-SourceBuild modes. + /// + /// The repo root directory containing artifacts/. + /// The temporary workspace where the local channel directory will be created. + /// The detected install mode. + /// + /// Optional additional package name prefixes to validate beyond Aspire.Hosting.. + /// For example, ["Aspire.Hosting.CodeGeneration.TypeScript.", "Aspire.Hosting.JavaScript."]. + /// + /// A with the packages path and SDK version, or null for non-SourceBuild. + internal static LocalChannelInfo? PrepareLocalChannel( + string repoRoot, + TemporaryWorkspace workspace, + DockerInstallMode installMode, + string[]? requiredPackagePrefixes = null) + { + if (installMode != DockerInstallMode.SourceBuild) + { + return null; + } + + var shippingPackagesDirectory = Path.Combine(repoRoot, "artifacts", "packages", "Debug", "Shipping"); + if (!Directory.Exists(shippingPackagesDirectory)) + { + throw new InvalidOperationException("Local source-built E2E tests require packed Aspire packages. Run './build.sh --bundle --pack' first."); + } + + var packageFiles = Directory.EnumerateFiles(shippingPackagesDirectory, "Aspire*.nupkg", SearchOption.TopDirectoryOnly) + .Where(file => !file.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase)) + .ToArray(); + + if (!packageFiles.Any(file => Path.GetFileName(file).StartsWith("Aspire.Hosting.", StringComparison.OrdinalIgnoreCase))) + { + throw new InvalidOperationException("Local source-built E2E tests require packed Aspire.Hosting packages. Run './build.sh --bundle --pack' first."); + } + + if (requiredPackagePrefixes is not null) + { + foreach (var prefix in requiredPackagePrefixes) + { + if (!packageFiles.Any(file => Path.GetFileName(file).StartsWith(prefix, StringComparison.OrdinalIgnoreCase))) + { + throw new InvalidOperationException($"Local source-built E2E tests require packed {prefix.TrimEnd('.')} packages. Run './build.sh --bundle --pack' first."); + } + } + } + + var localChannelPackagesPath = Path.Combine(workspace.WorkspaceRoot.FullName, ".aspire-local", "packages"); + Directory.CreateDirectory(localChannelPackagesPath); + + foreach (var packageFile in packageFiles) + { + File.Copy(packageFile, Path.Combine(localChannelPackagesPath, Path.GetFileName(packageFile)), overwrite: true); + } + + var sdkVersion = packageFiles + .Select(Path.GetFileName) + .FirstOrDefault(fileName => fileName is not null && Regex.IsMatch(fileName, @"^Aspire\.Hosting\.\d+\.\d+\.\d+.*\.nupkg$", RegexOptions.IgnoreCase)) + ?.Replace("Aspire.Hosting.", string.Empty, StringComparison.OrdinalIgnoreCase) + ?.Replace(".nupkg", string.Empty, StringComparison.OrdinalIgnoreCase); + + if (string.IsNullOrEmpty(sdkVersion)) + { + throw new InvalidOperationException("Local source-built E2E tests could not determine the Aspire SDK version from packed packages."); + } + + return new LocalChannelInfo(localChannelPackagesPath, sdkVersion); + } + + /// + /// Information about a local NuGet package channel for source-build E2E tests. + /// + /// The directory path containing the local .nupkg files. + /// The Aspire SDK version extracted from the package filenames. + internal sealed record LocalChannelInfo(string PackagesPath, string SdkVersion); } diff --git a/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs index 67b358aa9d0..56180c8c52d 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Text.Json.Nodes; using Aspire.Cli.EndToEnd.Tests.Helpers; using Aspire.Cli.Tests.Utils; using Hex1b.Automation; @@ -96,4 +97,149 @@ public async Task CreateTypeScriptAppHostWithViteApp() await pendingRun; } + + [Fact] + public async Task InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot() + { + var repoRoot = CliE2ETestHelpers.GetRepoRoot(); + var installMode = CliE2ETestHelpers.DetectDockerInstallMode(repoRoot); + var workspace = TemporaryWorkspace.Create(output); + var localChannel = CliE2ETestHelpers.PrepareLocalChannel(repoRoot, workspace, installMode, + ["Aspire.Hosting.CodeGeneration.TypeScript.", "Aspire.Hosting.JavaScript."]); + var channelArgument = localChannel is not null ? " --channel local" : string.Empty; + + using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, installMode, output, variant: CliE2ETestHelpers.DockerfileVariant.DotNet, mountDockerSocket: true, workspace: workspace); + + var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken); + + string? originalDevScript = null; + string? originalBuildScript = null; + string? originalPreviewScript = null; + string? originalTsConfig = null; + + var counter = new SequenceCounter(); + var auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500)); + + await auto.PrepareDockerEnvironmentAsync(counter, workspace); + + await auto.InstallAspireCliInDockerAsync(installMode, counter); + + await auto.EnablePolyglotSupportAsync(counter); + + if (localChannel is not null) + { + var containerLocalChannelPackagesPath = CliE2ETestHelpers.ToContainerPath(localChannel.PackagesPath, workspace); + await auto.TypeAsync($"mkdir -p ~/.aspire/hives/local && rm -rf ~/.aspire/hives/local/packages && ln -s '{containerLocalChannelPackagesPath}' ~/.aspire/hives/local/packages"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + } + + // Create brownfield Vite project + await auto.TypeAsync("mkdir brownfield && cd brownfield"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + + await auto.TypeAsync("npm create -y vite@latest . -- --template vanilla-ts --no-interactive"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter, TimeSpan.FromMinutes(2)); + + // Capture original package.json scripts and tsconfig before aspire init + var projectRoot = Path.Combine(workspace.WorkspaceRoot.FullName, "brownfield"); + var packageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "package.json")))!.AsObject(); + var scripts = packageJson["scripts"]!.AsObject(); + originalDevScript = scripts["dev"]?.GetValue(); + originalBuildScript = scripts["build"]?.GetValue(); + originalPreviewScript = scripts["preview"]?.GetValue(); + originalTsConfig = File.ReadAllText(Path.Combine(projectRoot, "tsconfig.json")); + + if (localChannel is not null) + { + WriteLocalChannelSettings(projectRoot, localChannel.SdkVersion); + } + + // Run aspire init in brownfield mode + await auto.TypeAsync($"aspire init --language typescript --non-interactive{channelArgument}"); + await auto.EnterAsync(); + await auto.WaitUntilTextAsync("Created apphost.ts", timeout: TimeSpan.FromMinutes(2)); + await auto.DeclineAgentInitPromptAsync(counter); + + // Verify brownfield augmentation preserved existing config + Assert.NotNull(originalDevScript); + Assert.NotNull(originalBuildScript); + Assert.NotNull(originalPreviewScript); + Assert.NotNull(originalTsConfig); + + packageJson = JsonNode.Parse(File.ReadAllText(Path.Combine(projectRoot, "package.json")))!.AsObject(); + scripts = packageJson["scripts"]!.AsObject(); + var dependencies = packageJson["dependencies"]!.AsObject(); + var devDependencies = packageJson["devDependencies"]!.AsObject(); + + Assert.Equal(originalDevScript, scripts["dev"]?.GetValue()); + Assert.Equal(originalBuildScript, scripts["build"]?.GetValue()); + Assert.Equal(originalPreviewScript, scripts["preview"]?.GetValue()); + Assert.Equal("aspire run", scripts["aspire:start"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("npm run aspire:start", scripts["start"]?.GetValue()); + + Assert.Equal("module", packageJson["type"]?.GetValue()); + Assert.NotNull(dependencies["vscode-jsonrpc"]); + Assert.NotNull(devDependencies["@types/node"]); + Assert.NotNull(devDependencies["nodemon"]); + Assert.NotNull(devDependencies["tsx"]); + Assert.NotNull(devDependencies["typescript"]); + + Assert.Equal(originalTsConfig, File.ReadAllText(Path.Combine(projectRoot, "tsconfig.json"))); + Assert.True(File.Exists(Path.Combine(projectRoot, "tsconfig.apphost.json"))); + + // Verify Aspire.Hosting.JavaScript was pre-added in config + var configPath = Path.Combine(projectRoot, "aspire.config.json"); + var config = JsonNode.Parse(File.ReadAllText(configPath))!.AsObject(); + var packagesNode = config["packages"]; + Assert.NotNull(packagesNode); + var packages = packagesNode!.AsObject(); + Assert.NotNull(packages["Aspire.Hosting.JavaScript"]); + + // Modify apphost.ts to add the Vite app before running + var appHostPath = Path.Combine(projectRoot, "apphost.ts"); + var newContent = """ + // Aspire TypeScript AppHost + // For more information, see: https://aspire.dev + + import { createBuilder } from './.modules/aspire.js'; + + const builder = await createBuilder(); + + await builder.addViteApp("brownfield", "."); + + await builder.build().run(); + """; + + File.WriteAllText(appHostPath, newContent); + + // Run the apphost to verify it works + await auto.TypeAsync("aspire run"); + await auto.EnterAsync(); + await auto.WaitUntilTextAsync("Press CTRL+C to stop the apphost and exit.", timeout: TimeSpan.FromMinutes(3)); + + await auto.Ctrl().KeyAsync(Hex1bKey.C); + await auto.WaitForSuccessPromptAsync(counter); + await auto.TypeAsync("exit"); + await auto.EnterAsync(); + + await pendingRun; + } + + private static void WriteLocalChannelSettings(string projectRoot, string sdkVersion) + { + var configPath = Path.Combine(projectRoot, "aspire.config.json"); + + var config = new JsonObject + { + ["channel"] = "local", + ["sdk"] = new JsonObject { ["version"] = sdkVersion } + }; + + File.WriteAllText(configPath, config.ToJsonString()); + } } diff --git a/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterTemplateTests.cs b/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterTemplateTests.cs index 3b709ee6665..e1ca0341960 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterTemplateTests.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterTemplateTests.cs @@ -21,8 +21,16 @@ public async Task CreateAndRunTypeScriptStarterProject() var repoRoot = CliE2ETestHelpers.GetRepoRoot(); var installMode = CliE2ETestHelpers.DetectDockerInstallMode(repoRoot); var workspace = TemporaryWorkspace.Create(output); + var localChannel = CliE2ETestHelpers.PrepareLocalChannel(repoRoot, workspace, installMode); + var bundlePath = FindLocalBundlePath(repoRoot, installMode); - using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, installMode, output, mountDockerSocket: true, workspace: workspace); + var additionalVolumes = new List(); + if (bundlePath is not null) + { + additionalVolumes.Add($"{bundlePath}:/opt/aspire-bundle:ro"); + } + + using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, installMode, output, mountDockerSocket: true, workspace: workspace, additionalVolumes: additionalVolumes); var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken); @@ -32,6 +40,36 @@ public async Task CreateAndRunTypeScriptStarterProject() await auto.PrepareDockerEnvironmentAsync(counter, workspace); await auto.InstallAspireCliInDockerAsync(installMode, counter); + // Set up bundle layout for SourceBuild mode so the CLI can find + // aspire-managed and DCP relative to the CLI binary location. + if (bundlePath is not null) + { + await auto.TypeAsync("ln -s /opt/aspire-bundle/managed ~/.aspire/managed && ln -s /opt/aspire-bundle/dcp ~/.aspire/dcp"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + } + + // Set up local channel NuGet packages for SourceBuild mode so the + // CLI can resolve Aspire packages during template creation. + if (localChannel is not null) + { + var containerLocalChannelPackagesPath = CliE2ETestHelpers.ToContainerPath(localChannel.PackagesPath, workspace); + await auto.TypeAsync($"mkdir -p ~/.aspire/hives/local && rm -rf ~/.aspire/hives/local/packages && ln -s '{containerLocalChannelPackagesPath}' ~/.aspire/hives/local/packages"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + + // Set channel and SDK version globally so aspire new uses the local + // channel with the correct prerelease version (dev builds fall back to + // the last stable release by default, which won't match local packages). + await auto.TypeAsync("aspire config set channel local --global"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + + await auto.TypeAsync($"aspire config set sdk.version {localChannel.SdkVersion} --global"); + await auto.EnterAsync(); + await auto.WaitForSuccessPromptAsync(counter); + } + // Step 1: Create project using aspire new, selecting the Express/React template await auto.AspireNewAsync("TsStarterApp", counter, template: AspireTemplate.ExpressReact); @@ -63,4 +101,31 @@ public async Task CreateAndRunTypeScriptStarterProject() await pendingRun; } + + /// + /// Finds the extracted bundle layout directory for SourceBuild mode. + /// The bundle provides the aspire-managed server and DCP needed for template creation. + /// Returns null for non-SourceBuild modes (CI installs the full bundle via the PR script). + /// + private static string? FindLocalBundlePath(string repoRoot, CliE2ETestHelpers.DockerInstallMode installMode) + { + if (installMode != CliE2ETestHelpers.DockerInstallMode.SourceBuild) + { + return null; + } + + var bundlePath = Path.Combine(repoRoot, "artifacts", "bundle", "linux-x64"); + if (!Directory.Exists(bundlePath)) + { + throw new InvalidOperationException("Local source-built TypeScript E2E tests require the bundle layout. Run './build.sh --bundle' first."); + } + + var managedPath = Path.Combine(bundlePath, "managed", "aspire-managed"); + if (!File.Exists(managedPath)) + { + throw new InvalidOperationException($"Bundle layout is missing aspire-managed at {managedPath}. Run './build.sh --bundle' first."); + } + + return bundlePath; + } } diff --git a/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs index b46f070343c..2467e4466f3 100644 --- a/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs @@ -1342,7 +1342,7 @@ public async Task NewCommandWithTypeScriptStarterGeneratesSdkArtifacts() services.AddSingleton(new TestTypeScriptStarterProjectFactory((directory, cancellationToken) => { buildAndGenerateCalled = true; - var config = AspireJsonConfiguration.Load(directory.FullName); + var config = AspireConfigFile.Load(directory.FullName); channelSeenByProject = config?.Channel; var modulesDir = Directory.CreateDirectory(Path.Combine(directory.FullName, ".modules")); diff --git a/tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs b/tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs index c6b147b400b..4549f6beabe 100644 --- a/tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs @@ -6,12 +6,24 @@ using Aspire.Cli.Tests.TestServices; using Aspire.Cli.Utils; using Aspire.TypeSystem; -using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging; namespace Aspire.Cli.Tests.Projects; -public class GuestRuntimeTests +public class GuestRuntimeTests(ITestOutputHelper outputHelper) { + private readonly ILoggerFactory _loggerFactory = LoggerFactory.Create(builder => builder.AddXunit(outputHelper)); + + private GuestRuntime CreateRuntime( + RuntimeSpec? spec = null, + Func? commandResolver = null) + { + return new GuestRuntime( + spec ?? CreateTestSpec(), + _loggerFactory.CreateLogger(), + commandResolver: commandResolver); + } + private static RuntimeSpec CreateTestSpec( CommandSpec? execute = null, CommandSpec? watchExecute = null, @@ -38,7 +50,7 @@ private static RuntimeSpec CreateTestSpec( [Fact] public void Language_ReturnsSpecLanguage() { - var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + var runtime = CreateRuntime(); Assert.Equal("test/runtime", runtime.Language); } @@ -46,7 +58,7 @@ public void Language_ReturnsSpecLanguage() [Fact] public void DisplayName_ReturnsSpecDisplayName() { - var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + var runtime = CreateRuntime(); Assert.Equal("Test Runtime", runtime.DisplayName); } @@ -54,7 +66,7 @@ public void DisplayName_ReturnsSpecDisplayName() [Fact] public void CreateDefaultLauncher_ReturnsProcessGuestLauncher() { - var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + var runtime = CreateRuntime(); var launcher = runtime.CreateDefaultLauncher(); @@ -69,7 +81,7 @@ public async Task RunAsync_UsesExecuteSpec() Command = "my-runner", Args = ["{appHostFile}"] }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -88,7 +100,7 @@ public async Task RunAsync_WatchMode_UsesWatchExecuteSpec() execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }, watchExecute: new CommandSpec { Command = "watch-cmd", Args = ["--watch", "{appHostFile}"] } ); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -103,7 +115,7 @@ public async Task RunAsync_WatchMode_UsesWatchExecuteSpec() public async Task RunAsync_WatchModeWithoutWatchSpec_FallsBackToExecute() { var spec = CreateTestSpec(execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -120,7 +132,7 @@ public async Task PublishAsync_UsesPublishExecuteSpec() execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }, publishExecute: new CommandSpec { Command = "publish-cmd", Args = ["{appHostFile}", "{args}"] } ); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -135,7 +147,7 @@ public async Task PublishAsync_UsesPublishExecuteSpec() public async Task PublishAsync_WithoutPublishSpec_FallsBackToExecute() { var spec = CreateTestSpec(execute: new CommandSpec { Command = "run-cmd", Args = ["{appHostFile}"] }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -154,7 +166,7 @@ public async Task RunAsync_MergesSpecEnvironmentVariables() Args = ["{appHostFile}"], EnvironmentVariables = new Dictionary { ["SPEC_VAR"] = "spec_value" } }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -175,7 +187,7 @@ public async Task RunAsync_SpecEnvironmentVariables_TakePrecedence() Args = ["{appHostFile}"], EnvironmentVariables = new Dictionary { ["SHARED_VAR"] = "from_spec" } }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -194,7 +206,7 @@ public async Task RunAsync_ReplacesAppHostFilePlaceholder() Command = "npx", Args = ["tsx", "{appHostFile}"] }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/home/user/project/apphost.ts"); var directory = new DirectoryInfo("/home/user/project"); @@ -213,7 +225,7 @@ public async Task RunAsync_ReplacesAppHostDirPlaceholder() Command = "test-cmd", Args = ["--dir", "{appHostDir}"] }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/home/user/project/apphost.ts"); var directory = new DirectoryInfo("/home/user/project"); @@ -231,7 +243,7 @@ public async Task PublishAsync_AdditionalArgsAppendedWhenNoPlaceholder() Command = "test-cmd", Args = ["{appHostFile}"] }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -251,7 +263,7 @@ public async Task RunAsync_EmptyPlaceholderReplacementsAreSkipped() Command = "test-cmd", Args = ["{args}"] }); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var launcher = new RecordingLauncher(); var appHostFile = new FileInfo("/tmp/apphost.ts"); var directory = new DirectoryInfo("/tmp"); @@ -273,7 +285,7 @@ public void ExtensionLaunchCapability_ReturnsSpecValue() Execute = new CommandSpec { Command = "test-cmd", Args = ["{appHostFile}"] }, ExtensionLaunchCapability = "node" }; - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); Assert.Equal("node", runtime.ExtensionLaunchCapability); } @@ -281,7 +293,7 @@ public void ExtensionLaunchCapability_ReturnsSpecValue() [Fact] public void ExtensionLaunchCapability_DefaultsToNull() { - var runtime = new GuestRuntime(CreateTestSpec(), NullLogger.Instance); + var runtime = CreateRuntime(); Assert.Null(runtime.ExtensionLaunchCapability); } @@ -290,7 +302,7 @@ public void ExtensionLaunchCapability_DefaultsToNull() public async Task InstallDependenciesAsync_WithNoSpec_ReturnsZero() { var spec = CreateTestSpec(); - var runtime = new GuestRuntime(spec, NullLogger.Instance); + var runtime = CreateRuntime(spec); var (exitCode, output) = await runtime.InstallDependenciesAsync(new DirectoryInfo("/tmp"), CancellationToken.None); @@ -301,7 +313,7 @@ public async Task InstallDependenciesAsync_WithNoSpec_ReturnsZero() [Fact] public async Task InstallDependenciesAsync_WhenNpmIsMissing_ReturnsNodeInstallMessage() { - var runtime = new GuestRuntime( + var runtime = CreateRuntime( new RuntimeSpec { Language = KnownLanguageId.TypeScript, @@ -311,7 +323,6 @@ public async Task InstallDependenciesAsync_WhenNpmIsMissing_ReturnsNodeInstallMe Execute = new CommandSpec { Command = "npx", Args = ["tsx", "{appHostFile}"] }, InstallDependencies = new CommandSpec { Command = "npm", Args = ["install"] } }, - NullLogger.Instance, commandResolver: _ => null); var (exitCode, output) = await runtime.InstallDependenciesAsync(new DirectoryInfo(Path.GetTempPath()), CancellationToken.None); @@ -329,7 +340,7 @@ public async Task InstallDependenciesAsync_WhenNpmIsMissing_ReturnsNodeInstallMe [Fact] public async Task RunAsync_WhenNpxIsMissing_ReturnsNodeInstallMessage() { - var runtime = new GuestRuntime( + var runtime = CreateRuntime( new RuntimeSpec { Language = KnownLanguageId.TypeScript, @@ -338,7 +349,6 @@ public async Task RunAsync_WhenNpxIsMissing_ReturnsNodeInstallMessage() DetectionPatterns = ["apphost.ts"], Execute = new CommandSpec { Command = "npx", Args = ["tsx", "{appHostFile}"] } }, - NullLogger.Instance, commandResolver: _ => null); var appHostFile = new FileInfo(Path.Combine(Path.GetTempPath(), "apphost.ts")); @@ -372,7 +382,7 @@ public async Task ProcessGuestLauncher_WritesOutputToLogFile() var launcher = new ProcessGuestLauncher( "test", - NullLogger.Instance, + _loggerFactory.CreateLogger(), fileLoggerProvider, commandResolver: cmd => cmd == "dotnet" ? "dotnet" : null); @@ -411,6 +421,124 @@ public async Task ProcessGuestLauncher_WritesOutputToLogFile() } } + [Fact] + public async Task RunAsync_CreatesMissingMigrationFiles() + { + var tempDir = Path.Combine(Path.GetTempPath(), $"migration-test-{Guid.NewGuid()}"); + Directory.CreateDirectory(tempDir); + + try + { + var migrationFileName = "tsconfig.apphost.json"; + var migrationContent = """{ "compilerOptions": { "target": "ES2022" } }"""; + + var spec = new RuntimeSpec + { + Language = "test/runtime", + DisplayName = "Test Runtime", + CodeGenLanguage = "Test", + DetectionPatterns = ["apphost.test"], + Execute = new CommandSpec + { + Command = "test-cmd", + Args = ["--tsconfig", migrationFileName, "{appHostFile}"] + }, + MigrationFiles = new Dictionary + { + [migrationFileName] = migrationContent + } + }; + + var runtime = CreateRuntime(spec); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo(Path.Combine(tempDir, "apphost.ts")); + var directory = new DirectoryInfo(tempDir); + + // File should not exist before run + var migrationFilePath = Path.Combine(tempDir, migrationFileName); + Assert.False(File.Exists(migrationFilePath)); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: false, launcher, CancellationToken.None); + + // File should be created after run + Assert.True(File.Exists(migrationFilePath)); + var writtenContent = await File.ReadAllTextAsync(migrationFilePath); + Assert.Equal(migrationContent, writtenContent); + } + finally + { + Directory.Delete(tempDir, recursive: true); + } + } + + [Fact] + public async Task RunAsync_DoesNotOverwriteExistingMigrationFiles() + { + var tempDir = Path.Combine(Path.GetTempPath(), $"migration-test-{Guid.NewGuid()}"); + Directory.CreateDirectory(tempDir); + + try + { + var migrationFileName = "tsconfig.apphost.json"; + var migrationContent = """{ "compilerOptions": { "target": "ES2022" } }"""; + var existingContent = """{ "compilerOptions": { "target": "ES2020" } }"""; + + // Pre-create the file with different content + var migrationFilePath = Path.Combine(tempDir, migrationFileName); + await File.WriteAllTextAsync(migrationFilePath, existingContent); + + var spec = new RuntimeSpec + { + Language = "test/runtime", + DisplayName = "Test Runtime", + CodeGenLanguage = "Test", + DetectionPatterns = ["apphost.test"], + Execute = new CommandSpec + { + Command = "test-cmd", + Args = ["--tsconfig", migrationFileName, "{appHostFile}"] + }, + MigrationFiles = new Dictionary + { + [migrationFileName] = migrationContent + } + }; + + var runtime = CreateRuntime(spec); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo(Path.Combine(tempDir, "apphost.ts")); + var directory = new DirectoryInfo(tempDir); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: false, launcher, CancellationToken.None); + + // File should NOT be overwritten + var writtenContent = await File.ReadAllTextAsync(migrationFilePath); + Assert.Equal(existingContent, writtenContent); + } + finally + { + Directory.Delete(tempDir, recursive: true); + } + } + + [Fact] + public async Task RunAsync_NoMigrationFiles_ExecutesNormally() + { + var spec = CreateTestSpec(execute: new CommandSpec + { + Command = "test-cmd", + Args = ["{appHostFile}"] + }); + var runtime = CreateRuntime(spec); + var launcher = new RecordingLauncher(); + var appHostFile = new FileInfo("/tmp/apphost.ts"); + var directory = new DirectoryInfo("/tmp"); + + await runtime.RunAsync(appHostFile, directory, new Dictionary(), watchMode: false, launcher, CancellationToken.None); + + Assert.Equal("test-cmd", launcher.LastCommand); + } + private sealed class RecordingLauncher : IGuestProcessLauncher { public string LastCommand { get; private set; } = string.Empty; diff --git a/tests/Aspire.Cli.Tests/Scaffolding/PackageJsonMergerTests.cs b/tests/Aspire.Cli.Tests/Scaffolding/PackageJsonMergerTests.cs new file mode 100644 index 00000000000..ddc0ce3d275 --- /dev/null +++ b/tests/Aspire.Cli.Tests/Scaffolding/PackageJsonMergerTests.cs @@ -0,0 +1,1439 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json; +using System.Text.Json.Nodes; +using Aspire.Cli.Scaffolding; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Testing; + +namespace Aspire.Cli.Tests.Scaffolding; + +public class PackageJsonMergerTests +{ + private static string MergeJson(string existing, string scaffold) => + PackageJsonMerger.Merge(existing, scaffold, NullLogger.Instance); + + private static JsonObject ParseJson(string json) => + JsonNode.Parse(json)!.AsObject(); + + private static string GetScript(string mergedJson, string scriptName) => + ParseJson(mergedJson)["scripts"]![scriptName]?.GetValue()!; + + private static JsonObject GetScripts(string mergedJson) => + ParseJson(mergedJson)["scripts"]!.AsObject(); + + private static string? GetDep(string mergedJson, string section, string packageName) => + ParseJson(mergedJson)[section]?[packageName]?.GetValue(); + + [Fact] + public void ConflictingScripts_AddedWithAspirePrefix() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "dev": "vite", + "build": "vite build" + } + } + """; + + var scaffold = """ + { + "scripts": { + "dev": "aspire run", + "build": "tsc -p tsconfig.apphost.json", + "lint": "eslint apphost.ts" + } + } + """; + + var result = MergeJson(existing, scaffold); + var scripts = GetScripts(result); + + // Existing scripts preserved + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + + // Conflicting scaffold scripts get aspire: prefix + Assert.Equal("aspire run", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + + // Non-conflicting scaffold script added directly + Assert.Equal("eslint apphost.ts", scripts["lint"]?.GetValue()); + } + + [Fact] + public void NonConflictingScripts_AddedDirectly() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "test": "jest" + } + } + """; + + var scaffold = """ + { + "scripts": { + "dev": "aspire run", + "build": "tsc -p tsconfig.apphost.json", + "lint": "eslint apphost.ts" + } + } + """; + + var result = MergeJson(existing, scaffold); + var scripts = GetScripts(result); + + // Existing preserved + Assert.Equal("jest", scripts["test"]?.GetValue()); + + // All scaffold scripts added directly (no conflicts) + Assert.Equal("aspire run", scripts["dev"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["build"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["lint"]?.GetValue()); + } + + [Fact] + public void PrefixedScripts_AlwaysAdded() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "dev": "vite", + "build": "vite build" + } + } + """; + + var scaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:dev": "tsc --watch -p tsconfig.apphost.json", + "aspire:lint": "eslint apphost.ts" + } + } + """; + + var result = MergeJson(existing, scaffold); + var scripts = GetScripts(result); + + // Existing preserved + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + + // All aspire: scripts added + Assert.Equal("aspire run", scripts["aspire:start"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + } + + [Fact] + public void ConvenienceAliases_AddedForFreeNames() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "dev": "vite", + "build": "vite build" + } + } + """; + + var scaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:dev": "tsc --watch -p tsconfig.apphost.json", + "aspire:lint": "eslint apphost.ts" + } + } + """; + + var result = MergeJson(existing, scaffold); + var scripts = GetScripts(result); + + // "start" and "lint" are not taken — convenience aliases added + Assert.Equal("npm run aspire:start", scripts["start"]?.GetValue()); + Assert.Equal("npm run aspire:lint", scripts["lint"]?.GetValue()); + + // "dev" and "build" are taken — no alias + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + } + + [Fact] + public void NoAliasWhenNameTaken() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "start": "node server.js", + "lint": "prettier --check .", + "dev": "vite", + "build": "vite build" + } + } + """; + + var scaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "aspire:lint": "eslint apphost.ts", + "aspire:build": "tsc -p tsconfig.apphost.json" + } + } + """; + + var result = MergeJson(existing, scaffold); + var scripts = GetScripts(result); + + // All existing scripts preserved + Assert.Equal("node server.js", scripts["start"]?.GetValue()); + Assert.Equal("prettier --check .", scripts["lint"]?.GetValue()); + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + + // Aspire scripts added + Assert.Equal("aspire run", scripts["aspire:start"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + + // No convenience aliases — all unprefixed names are taken + // Verify the existing values weren't overwritten with aliases + Assert.Equal("node server.js", scripts["start"]?.GetValue()); + Assert.Equal("prettier --check .", scripts["lint"]?.GetValue()); + } + + [Fact] + public void MixedConflicts_SomeScriptsPrefixedSomeNot() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "dev": "vite", + "test": "jest" + } + } + """; + + var scaffold = """ + { + "scripts": { + "dev": "aspire run", + "build": "tsc -p tsconfig.apphost.json", + "aspire:lint": "eslint apphost.ts" + } + } + """; + + var result = MergeJson(existing, scaffold); + var scripts = GetScripts(result); + + // Existing preserved + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("jest", scripts["test"]?.GetValue()); + + // "dev" conflicted → prefixed + Assert.Equal("aspire run", scripts["aspire:dev"]?.GetValue()); + + // "build" didn't conflict → added directly + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["build"]?.GetValue()); + + // "aspire:lint" always added + alias since "lint" is free + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + Assert.Equal("npm run aspire:lint", scripts["lint"]?.GetValue()); + } + + [Fact] + public void Dependencies_SemverAwareMerge() + { + var existing = """ + { + "name": "my-app", + "dependencies": { + "express": "^4.18.0" + }, + "devDependencies": { + "typescript": "^5.0.0", + "vite": "^5.0.0" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "vscode-jsonrpc": "^8.2.0", + "express": "^5.0.0" + }, + "devDependencies": { + "typescript": "^5.9.3", + "@types/node": "^22.0.0", + "tsx": "^4.21.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Scaffold is newer — upgraded + Assert.Equal("^5.0.0", GetDep(result, "dependencies", "express")); + Assert.Equal("^5.9.3", GetDep(result, "devDependencies", "typescript")); + + // Not in scaffold — preserved + Assert.Equal("^5.0.0", GetDep(result, "devDependencies", "vite")); + + // New deps added + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + Assert.Equal("^22.0.0", GetDep(result, "devDependencies", "@types/node")); + Assert.Equal("^4.21.0", GetDep(result, "devDependencies", "tsx")); + } + + [Fact] + public void PreservesNonScriptProperties() + { + var existing = """ + { + "name": "my-existing-app", + "version": "3.0.0", + "description": "My cool app", + "private": true, + "type": "module", + "engines": { + "node": ">=18" + } + } + """; + + var scaffold = """ + { + "name": "aspire-apphost", + "version": "1.0.0", + "type": "commonjs", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "scripts": { + "aspire:build": "tsc -p tsconfig.apphost.json" + } + } + """; + + var result = MergeJson(existing, scaffold); + var json = ParseJson(result); + + // Existing scalars preserved + Assert.Equal("my-existing-app", json["name"]?.GetValue()); + Assert.Equal("3.0.0", json["version"]?.GetValue()); + Assert.Equal("My cool app", json["description"]?.GetValue()); + Assert.True(json["private"]?.GetValue()); + Assert.Equal("module", json["type"]?.GetValue()); + + // engines.node overwritten by scaffold (Aspire requires specific Node versions) + Assert.Equal("^20.19.0 || ^22.13.0 || >=24", json["engines"]?["node"]?.GetValue()); + + // Script from scaffold is added + Assert.Equal("tsc -p tsconfig.apphost.json", GetScript(result, "aspire:build")); + } + + [Fact] + public void EmptyExistingContent_ReturnsScaffold() + { + var scaffold = """ + { + "name": "aspire-apphost", + "scripts": { "dev": "aspire run" } + } + """; + + var result = MergeJson("", scaffold); + Assert.Equal(scaffold, result); + + result = MergeJson(" ", scaffold); + Assert.Equal(scaffold, result); + } + + [Fact] + public void MalformedExistingJson_ReturnsScaffold() + { + var scaffold = """ + { + "name": "aspire-apphost", + "scripts": { "dev": "aspire run" } + } + """; + + var result = MergeJson("not valid json {{{", scaffold); + Assert.Equal(scaffold, result); + } + + [Fact] + public void ExistingJsonWithCommentsAndTrailingCommas_MergesSuccessfully() + { + // Real-world package.json files may contain comments and trailing commas + // even though they're not valid per the JSON spec. We should tolerate them. + var existing = """ + { + // This is a comment + "name": "my-app", + "version": "1.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", // trailing comma + }, + "dependencies": { + "express": "^4.18.0", + } + } + """; + + var scaffold = """ + { + "scripts": { "aspire:start": "aspire run" }, + "dependencies": { "vscode-jsonrpc": "^8.2.0" } + } + """; + + var result = MergeJson(existing, scaffold); + var json = ParseJson(result); + + // Existing properties preserved (comments and trailing commas are stripped in output) + Assert.Equal("my-app", json["name"]?.GetValue()); + Assert.Equal("vite", GetScript(result, "dev")); + Assert.Equal("^4.18.0", GetDep(result, "dependencies", "express")); + + // Scaffold content merged in + Assert.Equal("aspire run", GetScript(result, "aspire:start")); + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + } + + [Fact] + public void Idempotent_MergingTwiceProducesSameResult() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "dependencies": { + "express": "^4.18.0" + } + } + """; + + var scaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:lint": "eslint apphost.ts" + }, + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var firstMerge = MergeJson(existing, scaffold); + var secondMerge = MergeJson(firstMerge, scaffold); + + // Parsing both to compare structurally (avoid whitespace differences) + var first = ParseJson(firstMerge); + var second = ParseJson(secondMerge); + + Assert.Equal( + first.ToJsonString(new JsonSerializerOptions { WriteIndented = true }), + second.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); + } + + [Fact] + public void NoExistingScripts_ScaffoldScriptsAddedDirectly() + { + var existing = """ + { + "name": "my-app", + "version": "1.0.0" + } + """; + + var scaffold = """ + { + "scripts": { + "dev": "aspire run", + "build": "tsc -p tsconfig.apphost.json", + "lint": "eslint apphost.ts" + } + } + """; + + var result = MergeJson(existing, scaffold); + var scripts = GetScripts(result); + + // All scripts added directly (no existing scripts to conflict) + Assert.Equal("aspire run", scripts["dev"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["build"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["lint"]?.GetValue()); + } + + [Fact] + public void StaleServer_AllScriptsPreservedUnderAspirePrefix() + { + // Simulates the exact scenario: stale server sends non-prefixed scripts, + // brownfield project already has dev/build/lint + var existing = """ + { + "name": "vite-project", + "version": "1.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "lint": "eslint . --ext .ts,.tsx", + "preview": "vite preview" + }, + "dependencies": { + "react": "^18.2.0" + }, + "devDependencies": { + "typescript": "^5.2.0", + "vite": "^5.0.0" + } + } + """; + + var staleScaffold = """ + { + "name": "aspire-apphost", + "version": "1.0.0", + "type": "module", + "scripts": { + "lint": "eslint apphost.ts", + "dev": "aspire run", + "build": "tsc -p tsconfig.apphost.json", + "watch": "tsc --watch -p tsconfig.apphost.json" + }, + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + }, + "devDependencies": { + "@types/node": "^22.0.0", + "tsx": "^4.21.0", + "typescript": "^5.9.3" + } + } + """; + + var result = MergeJson(existing, staleScaffold); + var json = ParseJson(result); + var scripts = json["scripts"]!.AsObject(); + + // Existing project identity preserved + Assert.Equal("vite-project", json["name"]?.GetValue()); + Assert.Equal("1.0.0", json["version"]?.GetValue()); + + // Existing scripts preserved + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + Assert.Equal("eslint . --ext .ts,.tsx", scripts["lint"]?.GetValue()); + Assert.Equal("vite preview", scripts["preview"]?.GetValue()); + + // Conflicting scaffold scripts added under aspire: prefix + Assert.Equal("aspire run", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + + // Non-conflicting scaffold script added directly + Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["watch"]?.GetValue()); + + // Existing deps preserved, new deps added, older deps upgraded + Assert.Equal("^18.2.0", GetDep(result, "dependencies", "react")); + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + Assert.Equal("^5.9.3", GetDep(result, "devDependencies", "typescript")); // upgraded from ^5.2.0 + Assert.Equal("^5.0.0", GetDep(result, "devDependencies", "vite")); + Assert.Equal("^22.0.0", GetDep(result, "devDependencies", "@types/node")); + Assert.Equal("^4.21.0", GetDep(result, "devDependencies", "tsx")); + } + + [Fact] + public void UpdatedServer_AllScriptsAndAliasesPresent() + { + // Simulates the updated server which already sends aspire: prefixed scripts + var existing = """ + { + "name": "vite-project", + "scripts": { + "dev": "vite", + "build": "vite build" + } + } + """; + + var updatedScaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:dev": "tsc --watch -p tsconfig.apphost.json", + "aspire:lint": "eslint apphost.ts" + }, + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var result = MergeJson(existing, updatedScaffold); + var scripts = GetScripts(result); + + // Existing preserved + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + + // All aspire: scripts present + Assert.Equal("aspire run", scripts["aspire:start"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + + // Convenience aliases for free names (start, lint not taken) + Assert.Equal("npm run aspire:start", scripts["start"]?.GetValue()); + Assert.Equal("npm run aspire:lint", scripts["lint"]?.GetValue()); + + // No aliases for taken names (dev, build already exist) + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + } + + [Fact] + public void ScriptCommands_PreservedWithFullFidelity() + { + // npm scripts commonly use &&, quotes, pipes, and other shell characters. + // The merger must write them back exactly as they were — no unicode escaping. + var existing = """ + { + "name": "my-app", + "scripts": { + "build": "tsc && vite build", + "dev": "concurrently \"tsc -w\" \"vite\"", + "test": "vitest run && echo 'done'", + "lint": "eslint . --ext .ts,.tsx && prettier --check .", + "clean": "rm -rf dist && rm -rf node_modules/.cache", + "start": "node server.js | tee output.log" + } + } + """; + + var scaffold = """ + { + "scripts": { + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:start": "aspire run" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Verify the raw JSON string contains literal &&, ', and | — not unicode escapes + Assert.Contains("tsc && vite build", result); + Assert.Contains("vitest run && echo 'done'", result); + Assert.Contains("eslint . --ext .ts,.tsx && prettier --check .", result); + Assert.Contains("rm -rf dist && rm -rf node_modules/.cache", result); + Assert.Contains("node server.js | tee output.log", result); + + // Quotes inside JSON string values are written as \" (valid JSON) — verify via raw string + Assert.Contains("concurrently \\\"tsc -w\\\" \\\"vite\\\"", result); + + // Must not contain unicode-escaped ampersands or single quotes + Assert.DoesNotContain("\\u0026", result); + Assert.DoesNotContain("\\u0027", result); + + // Also verify the parsed values round-trip correctly + var scripts = GetScripts(result); + Assert.Equal("tsc && vite build", scripts["build"]?.GetValue()); + Assert.Equal("concurrently \"tsc -w\" \"vite\"", scripts["dev"]?.GetValue()); + Assert.Equal("vitest run && echo 'done'", scripts["test"]?.GetValue()); + Assert.Equal("eslint . --ext .ts,.tsx && prettier --check .", scripts["lint"]?.GetValue()); + Assert.Equal("rm -rf dist && rm -rf node_modules/.cache", scripts["clean"]?.GetValue()); + Assert.Equal("node server.js | tee output.log", scripts["start"]?.GetValue()); + } + + [Fact] + public void ScaffoldScriptCommands_AlsoPreservedWithFullFidelity() + { + // Even scaffold-generated commands with special chars must be written faithfully + var existing = """ + { + "name": "my-app", + "scripts": { + "dev": "next dev" + } + } + """; + + var scaffold = """ + { + "scripts": { + "aspire:lint": "eslint apphost.ts && echo 'lint complete'", + "aspire:build": "tsc -p tsconfig.apphost.json && echo 'build done'" + } + } + """; + + var result = MergeJson(existing, scaffold); + + Assert.Contains("eslint apphost.ts && echo 'lint complete'", result); + Assert.Contains("tsc -p tsconfig.apphost.json && echo 'build done'", result); + Assert.DoesNotContain("\\u0026", result); + Assert.DoesNotContain("\\u0027", result); + } + + [Fact] + public void Dependencies_ScaffoldNewerVersion_Upgrades() + { + var existing = """ + { + "name": "my-app", + "devDependencies": { + "typescript": "^4.0.0" + } + } + """; + + var scaffold = """ + { + "devDependencies": { + "typescript": "^5.9.3" + } + } + """; + + var result = MergeJson(existing, scaffold); + Assert.Equal("^5.9.3", GetDep(result, "devDependencies", "typescript")); + } + + [Fact] + public void Dependencies_ExistingNewerVersion_Preserved() + { + var existing = """ + { + "name": "my-app", + "devDependencies": { + "typescript": "^6.0.0" + } + } + """; + + var scaffold = """ + { + "devDependencies": { + "typescript": "^5.9.3" + } + } + """; + + var result = MergeJson(existing, scaffold); + Assert.Equal("^6.0.0", GetDep(result, "devDependencies", "typescript")); + } + + [Fact] + public void Dependencies_TildeRange_Compared() + { + var existing = """ + { + "name": "my-app", + "devDependencies": { + "typescript": "~5.0.0" + } + } + """; + + var scaffold = """ + { + "devDependencies": { + "typescript": "^5.9.3" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Scaffold is newer (5.9.3 > 5.0.0), upgrades — entire value replaced including range operator + Assert.Equal("^5.9.3", GetDep(result, "devDependencies", "typescript")); + } + + [Fact] + public void Dependencies_UnionRange_Preserved() + { + var existing = """ + { + "name": "my-app", + "dependencies": { + "some-pkg": "^1.0.0 || ^2.0.0" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "some-pkg": "^3.0.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Union ranges are unparseable — existing preserved + Assert.Equal("^1.0.0 || ^2.0.0", GetDep(result, "dependencies", "some-pkg")); + } + + [Fact] + public void Dependencies_WorkspaceRef_Preserved() + { + var existing = """ + { + "name": "my-app", + "dependencies": { + "shared-lib": "workspace:*" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "shared-lib": "^1.0.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Workspace refs are not parseable as semver — existing preserved + Assert.Equal("workspace:*", GetDep(result, "dependencies", "shared-lib")); + } + + [Fact] + public void Dependencies_NewDependency_Added() + { + var existing = """ + { + "name": "my-app", + "dependencies": { + "express": "^4.18.0" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + Assert.Equal("^4.18.0", GetDep(result, "dependencies", "express")); + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + } + + [Fact] + public void NonStringScriptValue_SkippedGracefully() + { + var existing = """ + { + "name": "my-app", + "scripts": { + "dev": "vite" + } + } + """; + + // Scaffold has an array value for a script (unusual but should not crash) + var scaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "bad-script": [1, 2, 3] + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Valid scripts still merged, invalid ones skipped + Assert.Equal("vite", GetScript(result, "dev")); + Assert.Equal("aspire run", GetScript(result, "aspire:start")); + Assert.Null(ParseJson(result)["scripts"]!["bad-script"]); + } + + [Fact] + public void NonStringDependencyValue_SkippedGracefully() + { + var existing = """ + { + "name": "my-app", + "dependencies": { + "express": "^4.18.0" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "vscode-jsonrpc": "^8.2.0", + "bad-dep": ["1.0.0"] + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Valid deps merged, non-string ones skipped + Assert.Equal("^4.18.0", GetDep(result, "dependencies", "express")); + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + Assert.Null(GetDep(result, "dependencies", "bad-dep")); + } + + [Fact] + public void NonStringExistingDependency_PreservedNotCrashed() + { + var existing = """ + { + "name": "my-app", + "dependencies": { + "weird-pkg": { "version": "1.0.0", "optional": true } + } + } + """; + + var scaffold = """ + { + "dependencies": { + "weird-pkg": "^2.0.0", + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // Non-string existing dep preserved (upgrade skipped due to type mismatch) + var weirdPkg = ParseJson(result)["dependencies"]!["weird-pkg"]; + Assert.NotNull(weirdPkg); + Assert.True(weirdPkg is JsonObject); + + // New deps still added + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + } + + [Fact] + public void DependenciesSectionIsArray_HandledGracefully() + { + var existing = """ + { + "name": "my-app", + "dependencies": ["express", "react"] + } + """; + + var scaffold = """ + { + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // EnsureObject replaces the array with a proper object containing scaffold deps + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + } + + [Fact] + public void JsonRootIsArray_ReturnsScaffold() + { + var existing = """["not", "an", "object"]"""; + + var scaffold = """ + { + "name": "scaffold", + "scripts": { "dev": "aspire run" } + } + """; + + var result = MergeJson(existing, scaffold); + + // Can't merge into an array — returns scaffold as-is + Assert.Equal("scaffold", ParseJson(result)["name"]?.GetValue()); + } + + [Fact] + public void WildcardVersion_Preserved() + { + var existing = """ + { + "dependencies": { + "some-pkg": "*" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "some-pkg": "^2.0.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // "*" is unparseable — existing preserved + Assert.Equal("*", GetDep(result, "dependencies", "some-pkg")); + } + + [Fact] + public void LatestTag_Preserved() + { + var existing = """ + { + "dependencies": { + "some-pkg": "latest" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "some-pkg": "^2.0.0" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // "latest" is unparseable — existing preserved + Assert.Equal("latest", GetDep(result, "dependencies", "some-pkg")); + } + + [Fact] + public void PreReleaseVersion_ComparedCorrectly() + { + var existing = """ + { + "devDependencies": { + "typescript": "^5.9.3-beta.1" + } + } + """; + + var scaffold = """ + { + "devDependencies": { + "typescript": "^5.9.3" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // 5.9.3 release is newer than 5.9.3-beta.1 pre-release + Assert.Equal("^5.9.3", GetDep(result, "devDependencies", "typescript")); + } + + [Fact] + public void Engines_NodeConstraint_OverwrittenByScaffold() + { + var existing = """ + { + "name": "my-app", + "engines": { + "node": ">=16" + } + } + """; + + var scaffold = """ + { + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + } + """; + + var result = MergeJson(existing, scaffold); + + // engines.node is always overwritten — aspire init enforces Node version for ESLint 10 + var engines = ParseJson(result)["engines"]!.AsObject(); + Assert.Equal("^20.19.0 || ^22.13.0 || >=24", engines["node"]?.GetValue()); + } + + [Fact] + public void Engines_OtherKeys_Preserved() + { + var existing = """ + { + "name": "my-app", + "engines": { + "node": ">=16", + "npm": ">=8" + } + } + """; + + var scaffold = """ + { + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + } + """; + + var result = MergeJson(existing, scaffold); + + var engines = ParseJson(result)["engines"]!.AsObject(); + // node overwritten by scaffold + Assert.Equal("^20.19.0 || ^22.13.0 || >=24", engines["node"]?.GetValue()); + // npm preserved from existing + Assert.Equal(">=8", engines["npm"]?.GetValue()); + } + + [Fact] + public void Engines_AddedWhenMissing() + { + var existing = """ + { + "name": "my-app" + } + """; + + var scaffold = """ + { + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + } + """; + + var result = MergeJson(existing, scaffold); + + var engines = ParseJson(result)["engines"]!.AsObject(); + Assert.Equal("^20.19.0 || ^22.13.0 || >=24", engines["node"]?.GetValue()); + } + + [Fact] + public void ScaffoldWithArrayProperty_PreservesExistingArray() + { + var existing = """ + { + "name": "my-app", + "keywords": ["web", "api"] + } + """; + + var scaffold = """ + { + "keywords": ["web", "api"], + "files": ["dist/**", "README.md"] + } + """; + + // When both have an array, existing wins (preserved). Scaffold-only arrays are added. + var result = MergeJson(existing, scaffold); + var doc = JsonNode.Parse(result)!.AsObject(); + + var keywords = doc["keywords"]!.AsArray(); + Assert.Equal(2, keywords.Count); + Assert.Equal("web", keywords[0]!.GetValue()); + Assert.Equal("api", keywords[1]!.GetValue()); + + var files = doc["files"]!.AsArray(); + Assert.Equal(2, files.Count); + Assert.Equal("dist/**", files[0]!.GetValue()); + } + + [Fact] + public void BrownfieldNpmInit_MergesSuccessfully() + { + // Reproduces the real-world scenario where npm init creates a package.json + // and the scaffold produces only Aspire-desired entries (no echo of existing content). + var existing = """ + { + "name": "my-project", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "" + } + """; + + var scaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:lint": "eslint apphost.ts" + }, + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + }, + "devDependencies": { + "typescript": "^5.9.3", + "tsx": "^4.21.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + } + """; + + var result = MergeJson(existing, scaffold); + var doc = JsonNode.Parse(result)!.AsObject(); + + // Original fields preserved + Assert.Equal("my-project", doc["name"]!.GetValue()); + Assert.Equal("ISC", doc["license"]!.GetValue()); + + // Array preserved (empty keywords from npm init) + Assert.NotNull(doc["keywords"]); + Assert.IsAssignableFrom(doc["keywords"]); + + // Aspire scripts added, existing test script preserved + var scripts = doc["scripts"]!.AsObject(); + Assert.Contains("test", scripts.Select(p => p.Key)); + Assert.Contains("aspire:start", scripts.Select(p => p.Key)); + Assert.Contains("aspire:build", scripts.Select(p => p.Key)); + + // Dependencies merged + Assert.NotNull(doc["dependencies"]?["vscode-jsonrpc"]); + Assert.NotNull(doc["devDependencies"]?["typescript"]); + + // Engines set + Assert.Contains(">=24", doc["engines"]?["node"]?.GetValue()); + } + + [Fact] + public void EnsureObject_LogsWarning_WhenReplacingArrayWithObject() + { + var existing = """ + { + "name": "my-app", + "dependencies": ["express", "react"] + } + """; + + var scaffold = """ + { + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var sink = new TestSink(); + var logger = new TestLogger("test", sink, enabled: true); + + PackageJsonMerger.Merge(existing, scaffold, logger); + + var warning = Assert.Single(sink.Writes, w => w.LogLevel == LogLevel.Warning); + Assert.Contains("dependencies", warning.Formatter!(warning.State, null)!); + } + + [Fact] + public void EnsureObject_LogsWarning_WhenReplacingScalarWithObject() + { + var existing = """ + { + "name": "my-app", + "engines": "node >= 16" + } + """; + + var scaffold = """ + { + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + } + """; + + var sink = new TestSink(); + var logger = new TestLogger("test", sink, enabled: true); + + PackageJsonMerger.Merge(existing, scaffold, logger); + + var warning = Assert.Single(sink.Writes, w => w.LogLevel == LogLevel.Warning); + Assert.Contains("engines", warning.Formatter!(warning.State, null)!); + } + + [Fact] + public void EnsureObject_DoesNotLogWarning_WhenPropertyIsAlreadyObject() + { + var existing = """ + { + "name": "my-app", + "dependencies": { + "express": "^4.18.0" + } + } + """; + + var scaffold = """ + { + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var sink = new TestSink(); + var logger = new TestLogger("test", sink, enabled: true); + + PackageJsonMerger.Merge(existing, scaffold, logger); + + Assert.DoesNotContain(sink.Writes, w => w.LogLevel == LogLevel.Warning); + } + + [Fact] + public void EnsureObject_DoesNotLogWarning_WhenPropertyIsMissing() + { + var existing = """ + { + "name": "my-app" + } + """; + + var scaffold = """ + { + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + } + } + """; + + var sink = new TestSink(); + var logger = new TestLogger("test", sink, enabled: true); + + PackageJsonMerger.Merge(existing, scaffold, logger); + + Assert.DoesNotContain(sink.Writes, w => w.LogLevel == LogLevel.Warning); + } + + [Fact] + public void BrownfieldViteProject_AspireOnlyScaffold_MergesCorrectly() + { + // Simulates the full brownfield flow where the scaffold only contains + // Aspire-desired content (no echo of existing). This verifies the + // double-merge ordering dependency (item 3) is resolved: the merger + // does not produce incorrect aspire:-prefixed scripts from existing content. + var existing = """ + { + "name": "vite-brownfield", + "version": "2.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "vue": "^3.5.0" + }, + "devDependencies": { + "vite": "^7.0.0", + "typescript": "^5.0.0" + } + } + """; + + // Scaffold only has Aspire entries — no echo of existing content + var scaffold = """ + { + "scripts": { + "aspire:start": "aspire run", + "aspire:build": "tsc -p tsconfig.apphost.json", + "aspire:dev": "tsc --watch -p tsconfig.apphost.json", + "aspire:lint": "eslint apphost.ts" + }, + "dependencies": { + "vscode-jsonrpc": "^8.2.0" + }, + "devDependencies": { + "@types/node": "^22.0.0", + "eslint": "^10.0.3", + "nodemon": "^3.1.14", + "tsx": "^4.21.0", + "typescript": "^5.9.3", + "typescript-eslint": "^8.57.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + } + """; + + var result = MergeJson(existing, scaffold); + var doc = JsonNode.Parse(result)!.AsObject(); + + // Existing metadata preserved + Assert.Equal("vite-brownfield", doc["name"]!.GetValue()); + Assert.Equal("2.0.0", doc["version"]!.GetValue()); + Assert.Equal("module", doc["type"]!.GetValue()); + + // Existing scripts preserved + var scripts = doc["scripts"]!.AsObject(); + Assert.Equal("vite", scripts["dev"]?.GetValue()); + Assert.Equal("vite build", scripts["build"]?.GetValue()); + Assert.Equal("vite preview", scripts["preview"]?.GetValue()); + + // Aspire scripts added (no incorrect aspire:dev duplicate from old "dev":"vite") + Assert.Equal("aspire run", scripts["aspire:start"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + + // No spurious aspire-prefixed duplicates of existing scripts + Assert.False(scripts.ContainsKey("aspire:preview")); + + // Existing deps preserved, Aspire deps added + Assert.Equal("^3.5.0", GetDep(result, "dependencies", "vue")); + Assert.Equal("^8.2.0", GetDep(result, "dependencies", "vscode-jsonrpc")); + + // Existing devDeps: vite preserved, typescript upgraded to Aspire's version (newer) + Assert.Equal("^7.0.0", GetDep(result, "devDependencies", "vite")); + Assert.Equal("^5.9.3", GetDep(result, "devDependencies", "typescript")); + Assert.Equal("^4.21.0", GetDep(result, "devDependencies", "tsx")); + + // Engines set + Assert.Contains(">=24", doc["engines"]?["node"]?.GetValue()); + } +} diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/TypeScriptLanguageSupportTests.cs b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/TypeScriptLanguageSupportTests.cs new file mode 100644 index 00000000000..d6ec5c78fed --- /dev/null +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/TypeScriptLanguageSupportTests.cs @@ -0,0 +1,220 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json.Nodes; +using Aspire.TypeSystem; + +namespace Aspire.Hosting.CodeGeneration.TypeScript.Tests; + +public sealed class TypeScriptLanguageSupportTests +{ + private readonly TypeScriptLanguageSupport _languageSupport = new(); + + [Fact] + public void Scaffold_CreatesAppHostSpecificScriptsAndTsConfig_ForNewProject() + { + using var testDirectory = new TestDirectory(); + + var files = _languageSupport.Scaffold(new ScaffoldRequest + { + TargetPath = testDirectory.Path, + ProjectName = "BrownfieldApp" + }); + + Assert.Contains("apphost.ts", files.Keys); + Assert.Contains("package.json", files.Keys); + Assert.Contains("tsconfig.apphost.json", files.Keys); + Assert.DoesNotContain("tsconfig.json", files.Keys); + + var packageJson = ParseJson(files["package.json"]); + var scripts = packageJson["scripts"]!.AsObject(); + var devDependencies = packageJson["devDependencies"]!.AsObject(); + + Assert.Equal("brownfieldapp", packageJson["name"]?.GetValue()); + Assert.Equal("1.0.0", packageJson["version"]?.GetValue()); + Assert.True(packageJson["private"]?.GetValue()); + Assert.Equal("module", packageJson["type"]?.GetValue()); + Assert.Equal("aspire run", scripts["aspire:start"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + Assert.False(scripts.ContainsKey("start")); + Assert.False(scripts.ContainsKey("build")); + Assert.False(scripts.ContainsKey("dev")); + Assert.Equal("^4.21.0", devDependencies["tsx"]?.GetValue()); + Assert.Equal("^5.9.3", devDependencies["typescript"]?.GetValue()); + Assert.Equal("^10.0.3", devDependencies["eslint"]?.GetValue()); + Assert.Equal("^8.57.1", devDependencies["typescript-eslint"]?.GetValue()); + + var engines = packageJson["engines"]!.AsObject(); + Assert.Equal("^20.19.0 || ^22.13.0 || >=24", engines["node"]?.GetValue()); + + // Verify the raw JSON does not contain unicode escapes for >= (fidelity check) + Assert.DoesNotContain("\\u003E", files["package.json"]); + + Assert.Contains("eslint.config.mjs", files.Keys); + + var tsConfig = ParseJson(files["tsconfig.apphost.json"]); + Assert.Equal("./dist/apphost", tsConfig["compilerOptions"]?["outDir"]?.GetValue()); + } + + [Fact] + public void Scaffold_BrownfieldOutput_ContainsOnlyAspireEntries() + { + using var testDirectory = new TestDirectory(); + + File.WriteAllText(Path.Combine(testDirectory.Path, "package.json"), """ + { + "name": "vite-brownfield", + "version": "2.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "aspire:start": "custom-start" + }, + "dependencies": { + "vscode-jsonrpc": "^9.9.9" + }, + "devDependencies": { + "tsx": "^9.9.9", + "vite": "^7.0.0" + } + } + """); + + var files = _languageSupport.Scaffold(new ScaffoldRequest + { + TargetPath = testDirectory.Path, + ProjectName = "Ignored" + }); + + var packageJson = ParseJson(files["package.json"]); + var scripts = packageJson["scripts"]!.AsObject(); + var dependencies = packageJson["dependencies"]!.AsObject(); + var devDependencies = packageJson["devDependencies"]!.AsObject(); + + // Scaffold output should NOT echo existing content — the CLI-side + // PackageJsonMerger handles combining with the on-disk file. + Assert.Null(packageJson["name"]); + Assert.Null(packageJson["version"]); + Assert.Null(packageJson["type"]); + Assert.Null(packageJson["private"]); + + // Scaffold should only contain Aspire-desired scripts + Assert.Equal("aspire run", scripts["aspire:start"]?.GetValue()); + Assert.Equal("tsc -p tsconfig.apphost.json", scripts["aspire:build"]?.GetValue()); + Assert.Equal("tsc --watch -p tsconfig.apphost.json", scripts["aspire:dev"]?.GetValue()); + Assert.Equal("eslint apphost.ts", scripts["aspire:lint"]?.GetValue()); + Assert.False(scripts.ContainsKey("dev")); + Assert.False(scripts.ContainsKey("build")); + Assert.False(scripts.ContainsKey("preview")); + + // Scaffold should only contain Aspire-desired dependencies (at Aspire's versions) + Assert.Equal("^8.2.0", dependencies["vscode-jsonrpc"]?.GetValue()); + Assert.Equal("^4.21.0", devDependencies["tsx"]?.GetValue()); + Assert.Equal("^22.0.0", devDependencies["@types/node"]?.GetValue()); + Assert.Equal("^3.1.14", devDependencies["nodemon"]?.GetValue()); + Assert.Equal("^5.9.3", devDependencies["typescript"]?.GetValue()); + Assert.False(devDependencies.ContainsKey("vite")); + + // engines.node is always set + var engines = packageJson["engines"]!.AsObject(); + Assert.Equal("^20.19.0 || ^22.13.0 || >=24", engines["node"]?.GetValue()); + } + + [Fact] + public void Scaffold_AlwaysOutputsAspireVersions_RegardlessOfExistingDependencies() + { + using var testDirectory = new TestDirectory(); + + File.WriteAllText(Path.Combine(testDirectory.Path, "package.json"), """ + { + "dependencies": { + "vscode-jsonrpc": "^8.1.0" + }, + "devDependencies": { + "@types/node": "^18.0.0", + "nodemon": "^3.1.0", + "tsx": "^4.18.0", + "typescript": "^5.2.0" + } + } + """); + + var files = _languageSupport.Scaffold(new ScaffoldRequest + { + TargetPath = testDirectory.Path, + ProjectName = "Ignored" + }); + + var packageJson = ParseJson(files["package.json"]); + var dependencies = packageJson["dependencies"]!.AsObject(); + var devDependencies = packageJson["devDependencies"]!.AsObject(); + + // Scaffold always produces Aspire's desired versions — the CLI-side + // PackageJsonMerger handles semver comparison with existing on-disk versions. + Assert.Equal("^8.2.0", dependencies["vscode-jsonrpc"]?.GetValue()); + Assert.Equal("^22.0.0", devDependencies["@types/node"]?.GetValue()); + Assert.Equal("^3.1.14", devDependencies["nodemon"]?.GetValue()); + Assert.Equal("^4.21.0", devDependencies["tsx"]?.GetValue()); + Assert.Equal("^5.9.3", devDependencies["typescript"]?.GetValue()); + } + + [Fact] + public void Scaffold_DoesNotEmitRootTsConfig_WhenOneAlreadyExists() + { + using var testDirectory = new TestDirectory(); + var existingTsConfigPath = Path.Combine(testDirectory.Path, "tsconfig.json"); + var existingTsConfig = """ + { + "compilerOptions": { + "module": "ESNext" + } + } + """; + + File.WriteAllText(existingTsConfigPath, existingTsConfig); + + var files = _languageSupport.Scaffold(new ScaffoldRequest + { + TargetPath = testDirectory.Path, + ProjectName = "BrownfieldApp" + }); + + Assert.DoesNotContain("tsconfig.json", files.Keys); + Assert.Contains("tsconfig.apphost.json", files.Keys); + Assert.Equal(existingTsConfig, File.ReadAllText(existingTsConfigPath)); + } + + [Fact] + public void GetRuntimeSpec_UsesAppHostSpecificTsConfig() + { + var runtimeSpec = _languageSupport.GetRuntimeSpec(); + var watchExecute = Assert.IsType(runtimeSpec.WatchExecute); + + Assert.Equal(new[] { "--no-install", "tsx", "--tsconfig", "tsconfig.apphost.json", "{appHostFile}" }, runtimeSpec.Execute.Args); + Assert.Contains("npx --no-install tsx --tsconfig tsconfig.apphost.json {appHostFile}", watchExecute.Args); + } + + private static JsonObject ParseJson(string content) => JsonNode.Parse(content)!.AsObject(); + + private sealed class TestDirectory : IDisposable + { + public TestDirectory() + { + Path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "aspire-ts-language-support-tests", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(Path); + } + + public string Path { get; } + + public void Dispose() + { + if (Directory.Exists(Path)) + { + Directory.Delete(Path, recursive: true); + } + } + } +} From f59dbc53ad7e486a695cd3694a69eaa87257b8fb Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 26 Mar 2026 10:27:20 -0700 Subject: [PATCH 41/49] Add rebuild guidance to Aspire skill for per-resource code changes (#15598) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add rebuild guidance to Aspire skill for per-resource code changes Update the skill content to teach agents when to restart the AppHost vs rebuild a single resource vs do nothing: - AppHost code changed → aspire start (full restart) - Compiled resource changed (C#, Go, etc.) → aspire resource rebuild - Interpreted resource (JS, Python) → no action (file watchers handle it) Add 'aspire resource rebuild' to the CLI command reference table and reinforce the rule in Important rules section. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Soften interpreted resource guidance per review feedback Acknowledge that not all JS/Python resources run in watch mode — suggest restarting the resource if no file watcher is configured. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Scope rebuild command to .NET project resources only Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add aspire describe --format Json hint for command discovery Agents can check which commands a resource supports before attempting rebuild, since it is only available on .NET project resources. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Nudge agents to use aspire docs search instead of NuGet XML docs Users report Copilot digging through NuGet package caches for XML doc files instead of using the built-in aspire docs search/get commands. Add an explicit rule telling agents to never search local package folders for Aspire documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Soften docs rule to prefer instead of hard block Use medium-freedom 'prefer X over Y' pattern instead of 'Do NOT' for documentation lookup guidance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Aspire.Cli/Agents/CommonAgentApplicators.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Aspire.Cli/Agents/CommonAgentApplicators.cs b/src/Aspire.Cli/Agents/CommonAgentApplicators.cs index 1fc5f4ca1cb..2dc4d40bdb0 100644 --- a/src/Aspire.Cli/Agents/CommonAgentApplicators.cs +++ b/src/Aspire.Cli/Agents/CommonAgentApplicators.cs @@ -165,6 +165,7 @@ This repository uses Aspire to orchestrate its distributed application. Resource | List resources | `aspire describe` or `aspire resources` | | Run resource command | `aspire resource ` | | Start/stop/restart resource | `aspire resource start|stop|restart` | + | Rebuild a .NET project resource | `aspire resource rebuild` | | View console logs | `aspire logs [resource]` | | View structured logs | `aspire otel logs [resource]` | | View traces | `aspire otel traces [resource]` | @@ -198,7 +199,17 @@ aspire start --isolated aspire wait myapi ``` - Relaunching is safe — `aspire start` automatically stops any previous instance. Re-run `aspire start` whenever changes are made to the AppHost project. + ### Applying code changes + + Choose the right action based on what changed: + + | What changed | Action | Why | + |---|---|---| + | AppHost project (`apphost.cs`/`apphost.ts`) | `aspire start` | Resource graph changed; full restart required | + | Compiled .NET project resource | `aspire resource rebuild` | Rebuilds and restarts only that resource | + | Interpreted resource (JavaScript, Python) | Typically nothing — most run with file watchers | Restart the resource if no watch mode is configured | + + **Never restart the entire AppHost just because a single resource changed.** Use `aspire resource rebuild` for .NET project resources — it coordinates stop, build, and restart for just that resource. Use `aspire describe --format Json` to check which commands a resource supports. ### Debugging issues @@ -229,9 +240,11 @@ aspire mcp tools --format Json # includes input s - **Always start the app first** (`aspire start`) before making changes to verify the starting state. - **To restart, just run `aspire start` again** — it automatically stops the previous instance. NEVER use `aspire stop` then `aspire run`. NEVER use `aspire run` at all. + - **Only restart the AppHost when AppHost code changes.** For .NET project resources, use `aspire resource rebuild` instead. - Use `--isolated` when working in a worktree. - **Avoid persistent containers** early in development to prevent state management issues. - **Never install the Aspire workload** — it is obsolete. + - **For Aspire API reference and documentation, prefer `aspire docs search ` and `aspire docs get `** over searching NuGet package caches or XML doc files. The CLI provides up-to-date content from aspire.dev. - Prefer `aspire.dev` and `learn.microsoft.com/microsoft/aspire` for official documentation. ## Playwright CLI From 38e5e0124e659bad53135a43415045d83848f5fe Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 27 Mar 2026 07:30:22 +0800 Subject: [PATCH 42/49] [release/13.2] Simplify TelemetryApiService.GetTrace and support short trace IDs (#15613) * Simplify TelemetryApiService.GetTrace and support short trace IDs - Use TelemetryRepository.GetTrace instead of fetching all traces - Add early return in GetTraceUnsynchronized for IDs shorter than ShortenedIdLength - Add parameterized unit test for full, short, and nonexistent trace IDs * Use hex constant in GetTrace test for explicit trace ID relationship * Remove early return for short trace IDs in GetTraceUnsynchronized MatchTelemetryId already handles short IDs correctly with exact equality fallback, so the guard was preventing valid exact-match lookups. * Clean up --- .../Api/TelemetryApiService.cs | 11 +---- .../TelemetryApiServiceTests.cs | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/Aspire.Dashboard/Api/TelemetryApiService.cs b/src/Aspire.Dashboard/Api/TelemetryApiService.cs index 112c2502a79..80617479ca7 100644 --- a/src/Aspire.Dashboard/Api/TelemetryApiService.cs +++ b/src/Aspire.Dashboard/Api/TelemetryApiService.cs @@ -167,16 +167,7 @@ internal sealed class TelemetryApiService( /// public TelemetryApiResponse? GetTrace(string traceId) { - var result = telemetryRepository.GetTraces(new GetTracesRequest - { - ResourceKey = null, - StartIndex = 0, - Count = MaxQueryCount, - Filters = [], - FilterText = string.Empty - }); - - var trace = result.PagedResult.Items.FirstOrDefault(t => OtlpHelpers.MatchTelemetryId(t.TraceId, traceId)); + var trace = telemetryRepository.GetTrace(traceId); if (trace is null) { return null; diff --git a/tests/Aspire.Dashboard.Tests/TelemetryApiServiceTests.cs b/tests/Aspire.Dashboard.Tests/TelemetryApiServiceTests.cs index 08be66566a8..8bd11576896 100644 --- a/tests/Aspire.Dashboard.Tests/TelemetryApiServiceTests.cs +++ b/tests/Aspire.Dashboard.Tests/TelemetryApiServiceTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Text; using Aspire.Dashboard.Api; using Aspire.Dashboard.Model; using Aspire.Dashboard.Otlp.Model; @@ -408,6 +409,50 @@ public async Task FollowLogsAsync_WithInvalidResourceName_ReturnsNoLogs() Assert.Empty(receivedItems); } + [Theory] + [InlineData("747261636531", true)] // full hex trace ID + [InlineData("7472616", true)] // shortened (7 char) prefix + [InlineData("747261", false)] // too short + [InlineData("nonexistent", false)] + public void GetTrace_VariousTraceIds_ReturnsExpectedResult(string lookupId, bool expectFound) + { + var repository = CreateRepository(); + var traceId = Encoding.UTF8.GetString(Convert.FromHexString("747261636531")); + + repository.AddTraces(new AddContext(), new RepeatedField + { + new ResourceSpans + { + Resource = CreateResource(name: "service1", instanceId: "inst1"), + ScopeSpans = + { + new ScopeSpans + { + Scope = CreateScope(), + Spans = + { + CreateSpan(traceId: traceId, spanId: "span1", startTime: s_testTime, endTime: s_testTime.AddMinutes(1)) + } + } + } + } + }); + + var service = CreateService(repository); + + var result = service.GetTrace(lookupId); + + if (expectFound) + { + Assert.NotNull(result); + Assert.Equal(1, result.ReturnedCount); + } + else + { + Assert.Null(result); + } + } + /// /// Creates a TelemetryApiService instance for testing with optional custom dependencies. /// From f2404186ff7fd4ce111713a2659f3aae2ecec4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 26 Mar 2026 20:37:21 -0700 Subject: [PATCH 43/49] Fix TS AppHost restore config resolution (#15625) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../DotNetBasedAppHostServerProject.cs | 4 +- .../Projects/PrebuiltAppHostServer.cs | 8 ++-- ...mplateFactory.TypeScriptStarterTemplate.cs | 12 +++--- .../Commands/NewCommandTests.cs | 3 ++ .../Projects/AppHostServerProjectTests.cs | 15 ++++---- .../Projects/PrebuiltAppHostServerTests.cs | 38 +++++++++++++++++++ 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs b/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs index 9b9663ba0f4..6abe0441159 100644 --- a/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs +++ b/src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs @@ -324,8 +324,8 @@ private XDocument CreateProjectFile(IEnumerable integratio } var channels = await _packagingService.GetChannelsAsync(cancellationToken); - var localConfig = AspireJsonConfiguration.Load(_appPath); - var configuredChannelName = localConfig?.Channel; + var configuredChannelName = AspireConfigFile.Load(_appPath)?.Channel + ?? AspireJsonConfiguration.Load(_appPath)?.Channel; if (string.IsNullOrEmpty(configuredChannelName)) { diff --git a/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs b/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs index 5c05e2a66d7..0bc97a6eada 100644 --- a/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs +++ b/src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs @@ -330,13 +330,13 @@ internal static string GenerateIntegrationProjectFile( } /// - /// Resolves the configured channel name from local settings.json or global config. + /// Resolves the configured channel name from local project config or global config. /// private async Task ResolveChannelNameAsync(CancellationToken cancellationToken) { - // Check local settings.json first - var localConfig = AspireJsonConfiguration.Load(_appDirectoryPath); - var channelName = localConfig?.Channel; + // Check aspire.config.json first, then fall back to legacy .aspire/settings.json. + var channelName = AspireConfigFile.Load(_appDirectoryPath)?.Channel + ?? AspireJsonConfiguration.Load(_appDirectoryPath)?.Channel; // Fall back to global config if (string.IsNullOrEmpty(channelName)) diff --git a/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs b/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs index cdb6fe354c0..0bff27ba9cd 100644 --- a/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs +++ b/src/Aspire.Cli/Templating/CliTemplateFactory.TypeScriptStarterTemplate.cs @@ -61,16 +61,14 @@ private async Task ApplyTypeScriptStarterTemplateAsync(CallbackT _logger.LogDebug("Copying embedded TypeScript starter template files to '{OutputPath}'.", outputPath); await CopyTemplateTreeToDiskAsync("ts-starter", outputPath, ApplyAllTokens, cancellationToken); - // Write channel to aspire.config.json before restore so package resolution uses the selected channel. + // Persist the template SDK version before restore so integration and codegen package + // resolution stays aligned with the project we just created. + var config = AspireConfigFile.LoadOrCreate(outputPath, aspireVersion); if (!string.IsNullOrEmpty(inputs.Channel)) { - var config = AspireConfigFile.Load(outputPath); - if (config is not null) - { - config.Channel = inputs.Channel; - config.Save(outputPath); - } + config.Channel = inputs.Channel; } + config.Save(outputPath); var appHostProject = _projectFactory.TryGetProject(new FileInfo(Path.Combine(outputPath, "apphost.ts"))); if (appHostProject is not IGuestAppHostSdkGenerator guestProject) diff --git a/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs index 2467e4466f3..1b2f3ed1605 100644 --- a/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs @@ -1296,6 +1296,7 @@ public async Task NewCommandWithTypeScriptStarterGeneratesSdkArtifacts() var buildAndGenerateCalled = false; string? channelSeenByProject = null; + string? sdkVersionSeenByProject = null; var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper, options => { @@ -1344,6 +1345,7 @@ public async Task NewCommandWithTypeScriptStarterGeneratesSdkArtifacts() buildAndGenerateCalled = true; var config = AspireConfigFile.Load(directory.FullName); channelSeenByProject = config?.Channel; + sdkVersionSeenByProject = config?.SdkVersion; var modulesDir = Directory.CreateDirectory(Path.Combine(directory.FullName, ".modules")); File.WriteAllText(Path.Combine(modulesDir.FullName, "aspire.ts"), "// generated sdk"); @@ -1360,6 +1362,7 @@ public async Task NewCommandWithTypeScriptStarterGeneratesSdkArtifacts() Assert.Equal(0, exitCode); Assert.True(buildAndGenerateCalled); Assert.Equal("daily", channelSeenByProject); + Assert.Equal("9.2.0", sdkVersionSeenByProject); Assert.True(File.Exists(Path.Combine(workspace.WorkspaceRoot.FullName, ".modules", "aspire.ts"))); } diff --git a/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs b/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs index 89ac6a12b2b..7b9d6c4ba34 100644 --- a/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/AppHostServerProjectTests.cs @@ -237,12 +237,12 @@ public void UserSecretsId_IsStableForSameAppPath() /// /// Regression test for channel switching bug. - /// When a project has a channel configured in .aspire/settings.json (project-local), + /// When a project has a channel configured in aspire.config.json (project-local), /// the NuGet.config should use that channel's hive path, NOT the global config channel. /// /// Bug scenario: /// 1. User runs `aspire update` and selects "pr-new" channel - /// 2. UpdatePackagesAsync saves channel="pr-new" to project-local .aspire/settings.json + /// 2. UpdatePackagesAsync saves channel="pr-new" to project-local aspire.config.json /// 3. BuildAndGenerateSdkAsync calls CreateProjectFilesAsync /// 4. BUG: CreateProjectFilesAsync reads channel from GLOBAL config (returns "pr-old") /// 5. NuGet.config is generated with pr-old hive path instead of pr-new @@ -259,14 +259,15 @@ public async Task CreateProjectFiles_NuGetConfig_UsesProjectLocalChannel_NotGlob var prOldHive = hivesDir.CreateSubdirectory("pr-old"); var prNewHive = hivesDir.CreateSubdirectory("pr-new"); - // Create project-local .aspire/settings.json with channel="pr-new" + // Create project-local aspire.config.json with channel="pr-new" // This simulates what happens after `aspire update` saves the selected channel - var aspireDir = _workspace.WorkspaceRoot.CreateSubdirectory(".aspire"); - var settingsJson = Path.Combine(aspireDir.FullName, "settings.json"); - await File.WriteAllTextAsync(settingsJson, """ + var aspireConfigPath = Path.Combine(_workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); + await File.WriteAllTextAsync(aspireConfigPath, """ { "channel": "pr-new", - "sdkVersion": "13.1.0" + "sdk": { + "version": "13.1.0" + } } """); diff --git a/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs b/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs index 8888eff0583..c4dbad8138f 100644 --- a/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/PrebuiltAppHostServerTests.cs @@ -192,4 +192,42 @@ public void Constructor_UsesUserAspireDirectoryForWorkingDirectory() } } + [Fact] + public async Task ResolveChannelNameAsync_UsesProjectLocalAspireConfig_NotGlobalChannel() + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var aspireConfigPath = Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); + await File.WriteAllTextAsync(aspireConfigPath, """ + { + "channel": "pr-new" + } + """); + + var configurationService = new TestConfigurationService + { + OnGetConfiguration = key => key == "channel" ? "pr-old" : null + }; + + var nugetService = new BundleNuGetService(new NullLayoutDiscovery(), Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance); + var server = new PrebuiltAppHostServer( + workspace.WorkspaceRoot.FullName, + "test.sock", + new LayoutConfiguration(), + nugetService, + new TestDotNetCliRunner(), + new TestDotNetSdkInstaller(), + new Aspire.Cli.Tests.Mcp.MockPackagingService(), + configurationService, + Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance); + + var method = typeof(PrebuiltAppHostServer).GetMethod("ResolveChannelNameAsync", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + Assert.NotNull(method); + + var channelTask = Assert.IsType>(method.Invoke(server, [CancellationToken.None])); + var channel = await channelTask; + + Assert.Equal("pr-new", channel); + } + } From 4ca8bbdf02f4c15826026e3ba2bbd786a9a3db62 Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Fri, 27 Mar 2026 10:05:52 -0700 Subject: [PATCH 44/49] Fix aspire new: move OpenEditor after agent init prompt (#15553) When running 'aspire new' from the VS Code extension, OpenEditor was called immediately after template creation, which opened the new workspace and severed the CLI terminal connection before the 'configure AI agent environments' prompt could be shown. Move OpenEditor to after PromptAndChainAsync so the full CLI interaction completes before the workspace switches. Fixes #15551 --- src/Aspire.Cli/Commands/NewCommand.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Aspire.Cli/Commands/NewCommand.cs b/src/Aspire.Cli/Commands/NewCommand.cs index b8b7e53eac2..9cd5c4c8d2d 100644 --- a/src/Aspire.Cli/Commands/NewCommand.cs +++ b/src/Aspire.Cli/Commands/NewCommand.cs @@ -278,13 +278,15 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell return templateResult.ExitCode; } + var workspaceRoot = new DirectoryInfo(templateResult.OutputPath ?? ExecutionContext.WorkingDirectory.FullName); + var exitCode = await _agentInitCommand.PromptAndChainAsync(_hostEnvironment, InteractionService, templateResult.ExitCode, workspaceRoot, cancellationToken); + if (templateResult.OutputPath is not null && ExtensionHelper.IsExtensionHost(InteractionService, out var extensionInteractionService, out _)) { extensionInteractionService.OpenEditor(templateResult.OutputPath); } - var workspaceRoot = new DirectoryInfo(templateResult.OutputPath ?? ExecutionContext.WorkingDirectory.FullName); - return await _agentInitCommand.PromptAndChainAsync(_hostEnvironment, InteractionService, templateResult.ExitCode, workspaceRoot, cancellationToken); + return exitCode; } private static bool ShouldResolveCliTemplateVersion(ITemplate template) From 7d78ca395e4e139976a321f0ca81cd6c37edf8a2 Mon Sep 17 00:00:00 2001 From: David Negstad <50252651+danegsta@users.noreply.github.com> Date: Fri, 27 Mar 2026 10:06:12 -0700 Subject: [PATCH 45/49] [release/13.2] Allow filtering endpoints from the default reference set (#15586) * Allow filtering endpoints from the default reference set (#15558) * Allow filtering endpoints from the default reference set * Update snapshots for codegen * Update the property to ExcludeReferenceEndpoint and make it false by default * Update test snapshot with outdated containerApps API version * release/13.2 --version check returns 13.2.1 now --- .../AzureCosmosDBExtensions.cs | 1 + .../AzureEventHubsExtensions.cs | 1 + .../AzureServiceBusExtensions.cs | 1 + .../KeycloakResourceBuilderExtensions.cs | 1 + .../ApplicationModel/EndpointAnnotation.cs | 14 ++ .../ApplicationModel/EndpointReference.cs | 9 ++ .../ResourceBuilderExtensions.cs | 37 ++++- ...TwoPassScanningGeneratedAspire.verified.go | 12 ++ ...oPassScanningGeneratedAspire.verified.java | 7 + ...TwoPassScanningGeneratedAspire.verified.py | 5 + ...TwoPassScanningGeneratedAspire.verified.rs | 8 ++ ...TwoPassScanningGeneratedAspire.verified.ts | 10 ++ .../WithReferenceTests.cs | 129 ++++++++++++++++++ 13 files changed, 229 insertions(+), 6 deletions(-) diff --git a/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs index e9cb111cb1c..1a622f91dfc 100644 --- a/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs +++ b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs @@ -136,6 +136,7 @@ private static IResourceBuilder RunAsEmulator(this IResou if (useVNextPreview) { builder.WithHttpEndpoint(name: EmulatorHealthEndpointName, targetPort: 8080) + .WithEndpoint(EmulatorHealthEndpointName, e => e.ExcludeReferenceEndpoint = true) .WithHttpHealthCheck(endpointName: EmulatorHealthEndpointName, path: "/ready") .WithUrlForEndpoint(EmulatorHealthEndpointName, u => u.DisplayLocation = UrlDisplayLocation.DetailsOnly); diff --git a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsExtensions.cs b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsExtensions.cs index 32e08696395..3513f5d7c04 100644 --- a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsExtensions.cs +++ b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsExtensions.cs @@ -258,6 +258,7 @@ public static IResourceBuilder RunAsEmulator(this IResou builder .WithEndpoint(name: "emulator", targetPort: 5672) .WithHttpEndpoint(name: EmulatorHealthEndpointName, targetPort: 5300) + .WithEndpoint(EmulatorHealthEndpointName, e => e.ExcludeReferenceEndpoint = true) .WithHttpHealthCheck(endpointName: EmulatorHealthEndpointName, path: "/health") .WithAnnotation(new ContainerImageAnnotation { diff --git a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs index 72a72514b83..9c9e41b7311 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs +++ b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs @@ -402,6 +402,7 @@ public static IResourceBuilder RunAsEmulator(this IReso builder .WithEndpoint(name: "emulator", targetPort: 5672) .WithHttpEndpoint(name: EmulatorHealthEndpointName, targetPort: 5300) + .WithEndpoint(EmulatorHealthEndpointName, e => e.ExcludeReferenceEndpoint = true) .WithAnnotation(new ContainerImageAnnotation { Registry = ServiceBusEmulatorContainerImageTags.Registry, diff --git a/src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs b/src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs index f05bccee709..a36b1b4af52 100644 --- a/src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs @@ -70,6 +70,7 @@ public static IResourceBuilder AddKeycloak( .WithImageTag(KeycloakContainerImageTags.Tag) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithHttpEndpoint(targetPort: ManagementInterfaceContainerPort, name: ManagementEndpointName) + .WithEndpoint(ManagementEndpointName, e => e.ExcludeReferenceEndpoint = true) .WithHttpHealthCheck(endpointName: ManagementEndpointName, path: "/health/ready") .WithOtlpExporter() .WithEnvironment(context => diff --git a/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs b/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs index 4ed71ad3b52..e5afeaa80f5 100644 --- a/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs +++ b/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs @@ -185,6 +185,20 @@ public string Transport /// Defaults to true. public bool IsProxied { get; set; } = true; + /// + /// Gets or sets a value indicating whether this endpoint is excluded from the default set when referencing the resource's endpoints + /// via WithReference(resource). When true, the endpoint is excluded from the default set and must be + /// referenced explicitly using WithReference(resource.GetEndpoint("name")). + /// + /// + /// Defaults to false. + /// + /// This is useful for resources that expose auxiliary endpoints (e.g., management dashboards, health check ports) + /// that should not be included in service discovery by default. + /// + /// + public bool ExcludeReferenceEndpoint { get; set; } + /// /// Gets or sets a value indicating whether TLS is enabled for this endpoint. /// diff --git a/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs b/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs index 271e080d34b..9ced43243de 100644 --- a/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs +++ b/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs @@ -69,6 +69,15 @@ public sealed class EndpointReference : IManifestExpressionProvider, IValueProvi /// public bool TlsEnabled => Exists && EndpointAnnotation.TlsEnabled; + /// + /// Gets a value indicating whether this endpoint is excluded from the default set when referencing the resource's endpoints. + /// + /// + /// Returns if the endpoint annotation has not been added to the resource yet. + /// Once the annotation exists, this property delegates to . + /// + public bool ExcludeReferenceEndpoint => Exists && EndpointAnnotation.ExcludeReferenceEndpoint; + string IManifestExpressionProvider.ValueExpression => GetExpression(); /// diff --git a/src/Aspire.Hosting/ResourceBuilderExtensions.cs b/src/Aspire.Hosting/ResourceBuilderExtensions.cs index d0568f41e28..e4df1c11681 100644 --- a/src/Aspire.Hosting/ResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ResourceBuilderExtensions.cs @@ -526,9 +526,12 @@ private static Action CreateEndpointReferenceEnviron } var endpointName = endpoint.EndpointName; - if (!annotation.UseAllEndpoints && !annotation.EndpointNames.Contains(endpointName)) + var isExplicitlyNamed = annotation.EndpointNames.Contains(endpointName); + var isIncludedByDefault = annotation.UseAllEndpoints && !endpoint.ExcludeReferenceEndpoint; + + if (!isExplicitlyNamed && !isIncludedByDefault) { - // Skip this endpoint since it's not in the list of endpoints we want to reference. + // Skip this endpoint since it's not explicitly named and not a default reference endpoint. continue; } @@ -810,14 +813,25 @@ public static ReferenceExpression GetConnectionProperty(this IResourceWithConnec } /// - /// Injects service discovery and endpoint information as environment variables from the project resource into the destination resource, using the source resource's name as the service name. - /// Each endpoint defined on the project resource will be injected using the format defined by the on the destination resource, i.e. + /// Injects service discovery and endpoint information as environment variables from the source resource into the destination resource, using the source resource's name as the service name. + /// Each non-excluded endpoint (where is false) defined on the source resource will be injected using the format defined by + /// the on the destination resource, i.e. /// either "services__{sourceResourceName}__{endpointScheme}__{endpointIndex}={uriString}" for .NET service discovery, or "{RESOURCE_ENDPOINT}={uri}" for endpoint injection. /// /// The destination resource. /// The resource where the service discovery information will be injected. /// The resource from which to extract service discovery information. /// The . + /// + /// + /// All endpoints are included in the default reference set unless explicitly excluded. + /// Resource authors can opt out individual endpoints by setting to true + /// (for example, using .WithEndpoint("endpointName", e => e.ExcludeReferenceEndpoint = true)) to exclude them from this method's behavior. + /// Endpoints that have been excluded (such as management or health check endpoints) can still be referenced explicitly using + /// + /// with . + /// + /// [AspireExportIgnore(Reason = "Polyglot app hosts use the generic withReference export.")] public static IResourceBuilder WithReference(this IResourceBuilder builder, IResourceBuilder source) where TDestination : IResourceWithEnvironment @@ -830,8 +844,9 @@ public static IResourceBuilder WithReference(this IR } /// - /// Injects service discovery and endpoint information as environment variables from the project resource into the destination resource, using the source resource's name as the service name. - /// Each endpoint defined on the project resource will be injected using the format defined by the on the destination resource, i.e. + /// Injects service discovery and endpoint information as environment variables from the source resource into the destination resource, using the source resource's name as the service name. + /// Each non-excluded endpoint (where is false) defined on the source resource will be injected using the format defined by + /// the on the destination resource, i.e. /// either "services__{name}__{endpointScheme}__{endpointIndex}={uriString}" for .NET service discovery, or "{name}_{ENDPOINT}={uri}" for endpoint injection. /// /// The destination resource. @@ -839,6 +854,16 @@ public static IResourceBuilder WithReference(this IR /// The resource from which to extract service discovery information. /// The name of the resource for the environment variable. /// The . + /// + /// + /// All endpoints are included in the default reference set unless explicitly excluded. + /// Resource authors can opt out individual endpoints by setting to true + /// (for example, using .WithEndpoint("endpointName", e => e.ExcludeReferenceEndpoint = true)) to exclude them from this method's behavior. + /// Endpoints that have been excluded (such as management or health check endpoints) can still be referenced explicitly using + /// + /// with . + /// + /// [AspireExportIgnore(Reason = "Polyglot app hosts use the generic withReference export.")] public static IResourceBuilder WithReference(this IResourceBuilder builder, IResourceBuilder source, string name) where TDestination : IResourceWithEnvironment diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go index 215bc231ff3..b63084eea8b 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go @@ -6064,6 +6064,18 @@ func (s *EndpointReference) TlsEnabled() (*bool, error) { return result.(*bool), nil } +// ExcludeReferenceEndpoint gets the ExcludeReferenceEndpoint property +func (s *EndpointReference) ExcludeReferenceEndpoint() (*bool, error) { + reqArgs := map[string]any{ + "context": SerializeValue(s.Handle()), + } + result, err := s.Client().InvokeCapability("Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint", reqArgs) + if err != nil { + return nil, err + } + return result.(*bool), nil +} + // Port gets the Port property func (s *EndpointReference) Port() (*float64, error) { reqArgs := map[string]any{ diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java index 37325d58db8..e696b870cf5 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java @@ -4370,6 +4370,13 @@ public boolean tlsEnabled() { return (boolean) getClient().invokeCapability("Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled", reqArgs); } + /** Gets the ExcludeReferenceEndpoint property */ + public boolean excludeReferenceEndpoint() { + Map reqArgs = new HashMap<>(); + reqArgs.put("context", AspireClient.serializeValue(getHandle())); + return (boolean) getClient().invokeCapability("Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint", reqArgs); + } + /** Gets the Port property */ public double port() { Map reqArgs = new HashMap<>(); diff --git a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py index 1ed8d96fecd..5a8337affcb 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py +++ b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py @@ -3061,6 +3061,11 @@ def tls_enabled(self) -> bool: args: Dict[str, Any] = { "context": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled", args) + def exclude_reference_endpoint(self) -> bool: + """Gets the ExcludeReferenceEndpoint property""" + args: Dict[str, Any] = { "context": serialize_value(self._handle) } + return self._client.invoke_capability("Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint", args) + def port(self) -> float: """Gets the Port property""" args: Dict[str, Any] = { "context": serialize_value(self._handle) } diff --git a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs index d1ba5360ef7..74126f7ea54 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs +++ b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs @@ -5351,6 +5351,14 @@ impl EndpointReference { Ok(serde_json::from_value(result)?) } + /// Gets the ExcludeReferenceEndpoint property + pub fn exclude_reference_endpoint(&self) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("context".to_string(), self.handle.to_json()); + let result = self.client.invoke_capability("Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint", args)?; + Ok(serde_json::from_value(result)?) + } + /// Gets the Port property pub fn port(&self) -> Result> { let mut args: HashMap = HashMap::new(); diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts index 11d33822cad..8eb9945b420 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts @@ -1200,6 +1200,16 @@ export class EndpointReference { }, }; + /** Gets the ExcludeReferenceEndpoint property */ + excludeReferenceEndpoint = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.excludeReferenceEndpoint', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { diff --git a/tests/Aspire.Hosting.Tests/WithReferenceTests.cs b/tests/Aspire.Hosting.Tests/WithReferenceTests.cs index 2c63f9472d9..bbfc60d94fb 100644 --- a/tests/Aspire.Hosting.Tests/WithReferenceTests.cs +++ b/tests/Aspire.Hosting.Tests/WithReferenceTests.cs @@ -801,6 +801,135 @@ private sealed class TestResource(string name) : Resource(name), IResourceWithCo ReferenceExpression.Create($"{ConnectionString}"); } + [Fact] + public async Task ExcludedReferenceEndpointExcludedFromUseAllEndpoints() + { + using var builder = TestDistributedApplicationBuilder.Create(); + + var projectA = builder.AddProject("projecta") + .WithHttpEndpoint(1000, 2000, "api") + .WithEndpoint("api", e => e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 2000)) + .WithHttpEndpoint(1000, 3000, "management") + .WithEndpoint("management", e => + { + e.ExcludeReferenceEndpoint = true; + e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 3000); + }); + + var projectB = builder.AddProject("projectb") + .WithReference(projectA); + + var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); + + // The "api" endpoint should be included (it's not excluded) + Assert.Equal("http://localhost:2000", config["services__projecta__http__0"]); + Assert.Equal("http://localhost:2000", config["PROJECTA_API"]); + + // The "management" endpoint should NOT be included (ExcludeReferenceEndpoint = true) + Assert.False(config.ContainsKey("services__projecta__http__1")); + Assert.False(config.ContainsKey("PROJECTA_MANAGEMENT")); + } + + [Fact] + public async Task ExcludedReferenceEndpointCanBeReferencedExplicitly() + { + using var builder = TestDistributedApplicationBuilder.Create(); + + var projectA = builder.AddProject("projecta") + .WithHttpEndpoint(1000, 2000, "api") + .WithEndpoint("api", e => e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 2000)) + .WithHttpEndpoint(1000, 3000, "management") + .WithEndpoint("management", e => + { + e.ExcludeReferenceEndpoint = true; + e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 3000); + }); + + // Explicitly reference the excluded endpoint + var projectB = builder.AddProject("projectb") + .WithReference(projectA.GetEndpoint("management")); + + var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); + + // The "management" endpoint should be included because it was explicitly referenced + Assert.Equal("http://localhost:3000", config["services__projecta__http__0"]); + Assert.Equal("http://localhost:3000", config["PROJECTA_MANAGEMENT"]); + + // The "api" endpoint should NOT be included (wasn't referenced) + Assert.False(config.ContainsKey("PROJECTA_API")); + } + + [Fact] + public async Task CombinedWithReferenceAndExplicitEndpointIncludesBoth() + { + using var builder = TestDistributedApplicationBuilder.Create(); + + var projectA = builder.AddProject("projecta") + .WithHttpEndpoint(1000, 2000, "api") + .WithEndpoint("api", e => e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 2000)) + .WithHttpEndpoint(1000, 3000, "management") + .WithEndpoint("management", e => + { + e.ExcludeReferenceEndpoint = true; + e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 3000); + }); + + // Reference all default endpoints AND the excluded management endpoint explicitly + var projectB = builder.AddProject("projectb") + .WithReference(projectA) + .WithReference(projectA.GetEndpoint("management")); + + var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); + + // Both endpoints should be included + Assert.Equal("http://localhost:2000", config["services__projecta__http__0"]); + Assert.Equal("http://localhost:3000", config["services__projecta__http__1"]); + Assert.Equal("http://localhost:2000", config["PROJECTA_API"]); + Assert.Equal("http://localhost:3000", config["PROJECTA_MANAGEMENT"]); + } + + [Fact] + public void ExcludeReferenceEndpointDefaultsToFalse() + { + using var builder = TestDistributedApplicationBuilder.Create(); + + var container = builder.AddContainer("mycontainer", "myimage") + .WithHttpEndpoint(targetPort: 8080); + + var endpoint = container.Resource.Annotations.OfType().Single(); + Assert.False(endpoint.ExcludeReferenceEndpoint); + } + + [Fact] + public void WithEndpointCallbackCanSetExcludeReferenceEndpoint() + { + using var builder = TestDistributedApplicationBuilder.Create(); + + var container = builder.AddContainer("mycontainer", "myimage") + .WithHttpEndpoint(targetPort: 8080, name: "api") + .WithEndpoint("api", e => e.ExcludeReferenceEndpoint = true); + + var endpoint = container.Resource.Annotations.OfType().Single(); + Assert.True(endpoint.ExcludeReferenceEndpoint); + } + + [Fact] + public void EndpointReferenceReflectsExcludeReferenceEndpoint() + { + using var builder = TestDistributedApplicationBuilder.Create(); + + var container = builder.AddContainer("mycontainer", "myimage") + .WithHttpEndpoint(targetPort: 8080, name: "primary") + .WithHttpEndpoint(targetPort: 9000, name: "management") + .WithEndpoint("management", e => e.ExcludeReferenceEndpoint = true); + + var primaryRef = container.GetEndpoint("primary"); + var managementRef = container.GetEndpoint("management"); + + Assert.False(primaryRef.ExcludeReferenceEndpoint); + Assert.True(managementRef.ExcludeReferenceEndpoint); + } + private sealed class TestResourceWithConnectionStringAndServiceDiscovery(string name) : ContainerResource(name), IResourceWithConnectionString, IResourceWithServiceDiscovery { public string? ConnectionString { get; set; } From 4d054c678d8e39ea94fffa41d2b7d66cd0cab81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Fri, 27 Mar 2026 10:08:49 -0700 Subject: [PATCH 46/49] [release/13.2] Fix guest AppHost launch profile env propagation (#15637) * Fix guest apphost launch profile env propagation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Reuse launch profile env values Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Projects/GuestAppHostProject.cs | 109 +++++++++++++----- .../Projects/GuestAppHostProjectTests.cs | 43 +++++++ 2 files changed, 124 insertions(+), 28 deletions(-) diff --git a/src/Aspire.Cli/Projects/GuestAppHostProject.cs b/src/Aspire.Cli/Projects/GuestAppHostProject.cs index 1024b27398c..d1809734fc1 100644 --- a/src/Aspire.Cli/Projects/GuestAppHostProject.cs +++ b/src/Aspire.Cli/Projects/GuestAppHostProject.cs @@ -383,8 +383,9 @@ public async Task RunAsync(AppHostProjectContext context, CancellationToken // Signal that build/preparation is complete context.BuildCompletionSource?.TrySetResult(true); - // Read launch settings and set shared environment variables - var launchSettingsEnvVars = GetServerEnvironmentVariables(directory); + // Read launch settings once and reuse them for both the temporary server and guest AppHost. + var launchProfileEnvironmentVariables = ReadLaunchSettingsEnvironmentVariables(directory); + var launchSettingsEnvVars = GetServerEnvironmentVariables(launchProfileEnvironmentVariables); // Apply certificate environment variables (e.g., SSL_CERT_DIR on Linux) foreach (var kvp in certEnvVars) @@ -470,14 +471,13 @@ await GenerateCodeViaRpcAsync( // Step 8: Execute the guest apphost - // Pass the socket path, project directory, and apphost file path to the guest process - var environmentVariables = new Dictionary(context.EnvironmentVariables) - { - ["REMOTE_APP_HOST_SOCKET_PATH"] = socketPath, - ["ASPIRE_PROJECT_DIRECTORY"] = directory.FullName, - ["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName, - [KnownConfigNames.RemoteAppHostToken] = authenticationToken - }; + // Pass the launch profile and certificate environment variables through to the guest AppHost + // so it sees the same dashboard and resource service endpoints as the temporary .NET server. + var environmentVariables = CreateGuestEnvironmentVariables(context.EnvironmentVariables, launchProfileEnvironmentVariables, certEnvVars); + environmentVariables["REMOTE_APP_HOST_SOCKET_PATH"] = socketPath; + environmentVariables["ASPIRE_PROJECT_DIRECTORY"] = directory.FullName; + environmentVariables["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName; + environmentVariables[KnownConfigNames.RemoteAppHostToken] = authenticationToken; // Check if the extension should launch the guest app host (for VS Code debugging). // This mirrors the pattern in DotNetCliRunner.ExecuteAsync for .NET app hosts. @@ -581,17 +581,70 @@ await GenerateCodeViaRpcAsync( internal Dictionary GetServerEnvironmentVariables(DirectoryInfo directory) { - var envVars = ReadLaunchSettingsEnvironmentVariables(directory) ?? new Dictionary(); + return GetServerEnvironmentVariables(ReadLaunchSettingsEnvironmentVariables(directory)); + } + + private static Dictionary GetServerEnvironmentVariables(IDictionary? launchProfileEnvironmentVariables) + { + var envVars = new Dictionary(); + MergeLaunchProfileEnvironmentVariables(launchProfileEnvironmentVariables, envVars, defaultEnvironment: "Development"); + return envVars; + } + + internal Dictionary CreateGuestEnvironmentVariables( + DirectoryInfo directory, + IDictionary contextEnvironmentVariables, + IDictionary? additionalEnvironmentVariables = null) + { + return CreateGuestEnvironmentVariables( + contextEnvironmentVariables, + ReadLaunchSettingsEnvironmentVariables(directory), + additionalEnvironmentVariables); + } - // Support ASPIRE_ENVIRONMENT from the launch profile to set both DOTNET_ENVIRONMENT and ASPNETCORE_ENVIRONMENT - envVars.TryGetValue("ASPIRE_ENVIRONMENT", out var environment); - environment ??= "Development"; + internal static Dictionary CreateGuestEnvironmentVariables( + IDictionary contextEnvironmentVariables, + IDictionary? launchProfileEnvironmentVariables, + IDictionary? additionalEnvironmentVariables = null) + { + var environmentVariables = new Dictionary(contextEnvironmentVariables); - // Set the environment for the AppHost server process - envVars["DOTNET_ENVIRONMENT"] = environment; - envVars["ASPNETCORE_ENVIRONMENT"] = environment; + MergeLaunchProfileEnvironmentVariables(launchProfileEnvironmentVariables, environmentVariables); - return envVars; + if (additionalEnvironmentVariables is not null) + { + foreach (var (key, value) in additionalEnvironmentVariables) + { + environmentVariables[key] = value; + } + } + + return environmentVariables; + } + + private static void MergeLaunchProfileEnvironmentVariables( + IDictionary? launchProfileEnvironmentVariables, + IDictionary environmentVariables, + string? defaultEnvironment = null) + { + if (launchProfileEnvironmentVariables is not null) + { + foreach (var (key, value) in launchProfileEnvironmentVariables) + { + environmentVariables[key] = value; + } + } + + if (launchProfileEnvironmentVariables?.TryGetValue("ASPIRE_ENVIRONMENT", out var environment) == true) + { + environmentVariables["DOTNET_ENVIRONMENT"] = environment; + environmentVariables["ASPNETCORE_ENVIRONMENT"] = environment; + } + else if (defaultEnvironment is not null) + { + environmentVariables["DOTNET_ENVIRONMENT"] = defaultEnvironment; + environmentVariables["ASPNETCORE_ENVIRONMENT"] = defaultEnvironment; + } } private Dictionary? ReadLaunchSettingsEnvironmentVariables(DirectoryInfo directory) @@ -765,8 +818,9 @@ public async Task PublishAsync(PublishContext context, CancellationToken ca // Store output collector in context for exception handling context.OutputCollector = prepareOutput; - // Read launch settings and set shared environment variables - var launchSettingsEnvVars = GetServerEnvironmentVariables(directory); + // Read launch settings once and reuse them for both the temporary server and guest AppHost. + var launchProfileEnvironmentVariables = ReadLaunchSettingsEnvironmentVariables(directory); + var launchSettingsEnvVars = GetServerEnvironmentVariables(launchProfileEnvironmentVariables); // Generate a backchannel socket path for CLI to connect to AppHost server var backchannelSocketPath = GetBackchannelSocketPath(); @@ -840,14 +894,13 @@ await GenerateCodeViaRpcAsync( cancellationToken); } - // Pass the socket path, project directory, and apphost file path to the guest process - var environmentVariables = new Dictionary(context.EnvironmentVariables) - { - ["REMOTE_APP_HOST_SOCKET_PATH"] = jsonRpcSocketPath, - ["ASPIRE_PROJECT_DIRECTORY"] = directory.FullName, - ["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName, - [KnownConfigNames.RemoteAppHostToken] = authenticationToken - }; + // Pass the launch profile environment variables through to the guest AppHost so publish mode + // uses the same dashboard and resource service endpoints as the temporary .NET server. + var environmentVariables = CreateGuestEnvironmentVariables(context.EnvironmentVariables, launchProfileEnvironmentVariables); + environmentVariables["REMOTE_APP_HOST_SOCKET_PATH"] = jsonRpcSocketPath; + environmentVariables["ASPIRE_PROJECT_DIRECTORY"] = directory.FullName; + environmentVariables["ASPIRE_APPHOST_FILEPATH"] = appHostFile.FullName; + environmentVariables[KnownConfigNames.RemoteAppHostToken] = authenticationToken; // Step 6: Execute the guest apphost for publishing // Pass the publish arguments (e.g., --operation publish --step deploy) diff --git a/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs b/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs index 0caee5d34db..380a0c555c8 100644 --- a/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs @@ -333,6 +333,49 @@ public void GetServerEnvironmentVariables_ParsesLaunchSettingsWithComments() Assert.False(envVars.ContainsKey("ASPIRE_DASHBOARD_OTLP_HTTP_ENDPOINT_URL")); } + [Fact] + public void CreateGuestEnvironmentVariables_MergesLaunchProfileContextAndAdditionalEnvironmentVariables() + { + var project = CreateGuestAppHostProject(); + + var aspireConfigPath = Path.Combine(_workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); + File.WriteAllText(aspireConfigPath, """ + { + "profiles": { + "https": { + "applicationUrl": "https://localhost:16319;http://localhost:16320", + "environmentVariables": { + "ASPIRE_ENVIRONMENT": "Staging", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:17269", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:18269" + } + } + } + } + """); + + var envVars = project.CreateGuestEnvironmentVariables( + _workspace.WorkspaceRoot, + new Dictionary + { + ["CUSTOM_CONTEXT_VARIABLE"] = "context", + ["ASPNETCORE_URLS"] = "http://context" + }, + new Dictionary + { + ["SSL_CERT_DIR"] = "/tmp/certs" + }); + + Assert.Equal("context", envVars["CUSTOM_CONTEXT_VARIABLE"]); + Assert.Equal("https://localhost:16319;http://localhost:16320", envVars["ASPNETCORE_URLS"]); + Assert.Equal("Staging", envVars["ASPIRE_ENVIRONMENT"]); + Assert.Equal("Staging", envVars["DOTNET_ENVIRONMENT"]); + Assert.Equal("Staging", envVars["ASPNETCORE_ENVIRONMENT"]); + Assert.Equal("https://localhost:17269", envVars["ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL"]); + Assert.Equal("https://localhost:18269", envVars["ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL"]); + Assert.Equal("/tmp/certs", envVars["SSL_CERT_DIR"]); + } + private static GuestAppHostProject CreateGuestAppHostProject() { var language = new LanguageInfo( From e6e46d22cc5fd07d49625cc5f14df88f12d34b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Fri, 27 Mar 2026 10:15:05 -0700 Subject: [PATCH 47/49] [release/13.2] Export more importable ATS hosting APIs (#15557) * Export more importable ATS hosting APIs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove legacy polyglot settings files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Unionize Foundry capability host export Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Unify addContainer ATS overloads Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refresh generated TS SDKs for addContainer union Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Regenerate polyglot codegen snapshots Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify TypeScript reference environment options Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Hide generated parameter ATS helper Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove stale addContainer remark Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix Go polyglot keyword escaping Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix polyglot validation regressions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Preserve connection property ATS alias Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refresh polyglot codegen snapshots Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ValidationAppHost/.aspire/settings.json | 7 - .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 8048 +++-- .../ValidationAppHost/.modules/base.ts | 145 +- .../ValidationAppHost/.modules/transport.ts | 579 +- .../ValidationAppHost/apphost.ts | 5 +- .../ValidationAppHost/aspire.config.json | 9 + .../ValidationAppHost/.aspire/settings.json | 7 - .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 11376 ++++-- .../ValidationAppHost/.modules/base.ts | 145 +- .../ValidationAppHost/.modules/transport.ts | 579 +- .../ValidationAppHost/apphost.ts | 3 + .../ValidationAppHost/aspire.config.json | 9 + .../ValidationAppHost/.aspire/settings.json | 7 - .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 8340 ++++- .../ValidationAppHost/.modules/base.ts | 74 +- .../ValidationAppHost/.modules/transport.ts | 540 +- .../ValidationAppHost/apphost.ts | 2 + .../ValidationAppHost/aspire.config.json | 9 + .../ValidationAppHost/.aspire/settings.json | 8 - .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 10180 ++++-- .../ValidationAppHost/.modules/base.ts | 145 +- .../ValidationAppHost/.modules/transport.ts | 579 +- .../ValidationAppHost/apphost.ts | 2 + .../ValidationAppHost/aspire.config.json | 10 + .../ValidationAppHost/.aspire/settings.json | 7 - .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 9493 +++-- .../ValidationAppHost/.modules/base.ts | 145 +- .../ValidationAppHost/.modules/transport.ts | 579 +- .../ValidationAppHost/apphost.ts | 7 + .../ValidationAppHost/aspire.config.json | 9 + .../ValidationAppHost/.aspire/settings.json | 8 - .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 28784 +++++++++++----- .../ValidationAppHost/.modules/base.ts | 145 +- .../ValidationAppHost/.modules/transport.ts | 579 +- .../ValidationAppHost/apphost.ts | 7 + .../ValidationAppHost/aspire.config.json | 11 + .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 7485 +++- .../ValidationAppHost/.modules/base.ts | 145 +- .../ValidationAppHost/.modules/transport.ts | 579 +- .../ValidationAppHost/apphost.ts | 25 +- .../ValidationAppHost/aspire.config.json | 18 + .../ValidationAppHost/.aspire/settings.json | 7 - .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 13125 +++++-- .../ValidationAppHost/.modules/base.ts | 74 +- .../ValidationAppHost/.modules/transport.ts | 540 +- .../ValidationAppHost/apphost.ts | 7 + .../ValidationAppHost/aspire.config.json | 9 + .../ValidationAppHost/.modules/.codegen-hash | 2 +- .../ValidationAppHost/.modules/aspire.ts | 2438 +- .../ValidationAppHost/.modules/base.ts | 34 +- .../ValidationAppHost/.modules/transport.ts | 442 +- .../ValidationAppHost/apphost.ts | 42 +- .../settings.json => aspire.config.json} | 6 +- .../AzureOpenAIDeploymentResource.cs | 4 - .../AzureOpenAIResource.cs | 1 + .../AzureEventHubResource.cs | 4 - .../AzureEventHubsResource.cs | 1 + .../AzureKustoClusterResource.cs | 4 - .../AzureKustoHealthCheckBuilderExtensions.cs | 2 +- .../AzureSubnetResource.cs | 1 + .../AzureVirtualNetworkResource.cs | 1 + .../AzureManagedRedisResource.cs | 4 - .../AzureServiceBusQueueResource.cs | 4 - .../AzureServiceBusResource.cs | 1 + .../AzureServiceBusSubscriptionResource.cs | 4 - .../AzureServiceBusTopicResource.cs | 4 - .../AzureSqlExtensions.cs | 5 +- .../AzureSqlServerResource.cs | 8 - .../ExistingAzureResourceExtensions.cs | 151 +- .../AtsGoCodeGenerator.cs | 6 +- .../AtsRustCodeGenerator.cs | 2 +- .../FoundryDeploymentResource.cs | 2 - src/Aspire.Hosting.Foundry/FoundryResource.cs | 1 + .../Project/ProjectBuilderExtension.cs | 134 +- .../ApplicationModel/ParameterDefault.cs | 1 + src/Aspire.Hosting/Ats/AddContainerOptions.cs | 21 + .../ReferenceEnvironmentInjectionOptions.cs | 64 + .../ContainerResourceBuilderExtensions.cs | 107 +- .../ParameterResourceBuilderExtensions.cs | 10 + .../ProjectResourceBuilderExtensions.cs | 7 +- .../ResourceBuilderExtensions.cs | 93 +- .../Helpers/CliE2EAutomatorHelpers.cs | 42 +- .../AtsGoCodeGeneratorTests.cs | 14 +- ...HostingAddContainerCapability.verified.txt | 29 +- ...TwoPassScanningGeneratedAspire.verified.go | 484 +- ...HostingAddContainerCapability.verified.txt | 29 +- ...oPassScanningGeneratedAspire.verified.java | 384 +- ...HostingAddContainerCapability.verified.txt | 29 +- ...TwoPassScanningGeneratedAspire.verified.py | 277 +- ...HostingAddContainerCapability.verified.txt | 29 +- ...TwoPassScanningGeneratedAspire.verified.rs | 435 +- ...HostingAddContainerCapability.verified.txt | 29 +- ...ContainerResourceCapabilities.verified.txt | 70 +- ...TwoPassScanningGeneratedAspire.verified.ts | 710 +- 102 files changed, 81433 insertions(+), 27351 deletions(-) delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.aspire/settings.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.aspire/settings.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.aspire/settings.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.aspire/settings.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.aspire/settings.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.aspire/settings.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json delete mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.aspire/settings.json create mode 100644 playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json rename playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/{.aspire/settings.json => aspire.config.json} (64%) create mode 100644 src/Aspire.Hosting/Ats/AddContainerOptions.cs create mode 100644 src/Aspire.Hosting/Ats/ReferenceEnvironmentInjectionOptions.cs diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.aspire/settings.json deleted file mode 100644 index a4cf5644401..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.aspire/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", - "packages": { - "Aspire.Hosting.Azure.CognitiveServices": "" - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/.codegen-hash index 6f023cf3085..2e231ad0a7c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -689F5DDD4CCEF83CFD8538D184AF85316AAABCEDF6A3ABD7F44BB914AFAC65D0 \ No newline at end of file +F113FAB0CF296E5CB6D4E0F7C3EB64496718342E77910A46C4DF0EC77BACCBBD \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/aspire.ts index 6b9eb438e5b..f3f880951ab 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/aspire.ts @@ -8,6 +8,8 @@ import { AspireClient as AspireClientRpc, Handle, MarshalledHandle, + AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -56,9 +58,21 @@ type BicepOutputReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Az /** Handle to IAzureKeyVaultSecretReference */ type IAzureKeyVaultSecretReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultSecretReference'>; +/** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -68,6 +82,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -92,6 +109,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -122,15 +142,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -155,18 +187,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -179,12 +226,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -239,6 +292,7 @@ export enum EndpointProperty { Scheme = "Scheme", TargetPort = "TargetPort", HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", } /** Enum type for IconVariant */ @@ -314,6 +368,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -344,6 +404,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -370,7 +451,7 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } -export interface AddContainerRegistry1Options { +export interface AddContainerRegistryFromStringOptions { repository?: string; } @@ -383,16 +464,21 @@ export interface AddDockerfileOptions { stage?: string; } -export interface AddParameter1Options { - publishValueAsDefault?: boolean; +export interface AddParameterFromConfigurationOptions { secret?: boolean; } -export interface AddParameterFromConfigurationOptions { +export interface AddParameterOptions { secret?: boolean; } -export interface AddParameterOptions { +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; secret?: boolean; } @@ -404,18 +490,84 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; +} + +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; } export interface RunOptions { - cancellationToken?: AbortSignal; + 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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithBindMountOptions { isReadOnly?: boolean; } @@ -424,6 +576,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDescriptionOptions { enableMarkdown?: boolean; } @@ -513,6 +671,7 @@ export interface WithPipelineStepFactoryOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -532,6 +691,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -573,6 +769,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -647,11 +917,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -666,6 +937,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -683,9 +1013,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -759,6 +1089,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -781,6 +1122,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -794,6 +1199,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -860,6 +1276,16 @@ export class EndpointReference { }, }; + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { @@ -914,13 +1340,22 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs ); } + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + 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 + ); + } + } /** @@ -941,6 +1376,11 @@ export class EndpointReferencePromise implements PromiseLike return this._promise.then(obj => obj.getValueAsync(options)); } + /** 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 { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + } // ============================================================================ @@ -1018,11 +1458,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1052,6 +1515,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1070,16 +1544,17 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; @@ -1087,35 +1562,127 @@ export class ExecuteCommandContext { } // ============================================================================ -// PipelineConfigurationContext +// InitializeResourceEvent // ============================================================================ /** - * Type class for PipelineConfigurationContext. + * Type class for InitializeResourceEvent. */ -export class PipelineConfigurationContext { - constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Steps property */ - steps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, - set: async (value: PipelineStep[]): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', - { context: this._handle, value } - ); - } }; - /** Gets pipeline steps with the specified tag */ + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + { context: this._handle } + ); + }, + set: async (value: PipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } + ); + } + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; return await this._client.invokeCapability( @@ -1146,6 +1713,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1233,6 +1887,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1303,6 +1968,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1314,18 +2012,159 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; } +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + +} + // ============================================================================ // ProjectResourceOptions // ============================================================================ @@ -1508,86 +2347,381 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new ServiceProvider(handle, this._client); }, }; } // ============================================================================ -// DistributedApplicationBuilder +// ResourceLoggerService // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for ResourceLoggerService. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, + /** Completes the log stream for a resource */ + /** @internal */ + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + } + + /** Completes the log stream by resource name */ + /** @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 ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); + } + + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ + /** @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 ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + } + + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** Waits for all dependencies of a resource to be ready */ + /** @internal */ + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + } + + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ + /** @internal */ + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, }; - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); }, }; @@ -1595,654 +2729,1759 @@ export class DistributedApplicationBuilder { executionContext = { get: async (): Promise => { const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', { context: this._handle } ); return new DistributedApplicationExecutionContext(handle, this._client); }, }; - /** Builds the distributed application */ - /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', rpcArgs ); - return new DistributedApplication(result, this._client); } - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); } - /** Adds a connection string with a reference expression */ - /** @internal */ - async _addConnectionString1Internal(name: string, connectionStringExpression: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringExpression', + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionString1Internal(name, connectionStringExpression)); + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); } - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', + /** Checks whether a configuration section exists */ + async exists(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/exists', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); +} + +/** + * Thenable wrapper for Configuration that enables fluent chaining. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + 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 ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @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 ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @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 DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @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 ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @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 ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds an Azure OpenAI resource */ + /** @internal */ + async _addAzureOpenAIInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.CognitiveServices/addAzureOpenAI', + rpcArgs + ); + return new AzureOpenAIResource(result, this._client); + } + + addAzureOpenAI(name: string): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._addAzureOpenAIInternal(name)); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds an Azure OpenAI resource */ + addAzureOpenAI(name: string): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.addAzureOpenAI(name))); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', + rpcArgs + ); + } + + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', + rpcArgs + ); + } + + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); + } + + /** Checks if the environment matches the specified name */ + 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. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); } - /** Adds a container registry resource */ - /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { - 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 ContainerRegistryResource(result, this._client); + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); } - /** Adds a container registry with string endpoint */ + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); + } + +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ /** @internal */ - async _addContainerRegistry1Internal(name: string, endpoint: string, repository?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistryFromString', + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return this; } - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistry1Internal(name, endpoint, repository)); + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._logInformationInternal(message)); } - /** Adds a container resource */ + /** Logs a warning message */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._logWarningInternal(message)); } - /** Adds a container resource built from a Dockerfile */ + /** Logs an error message */ /** @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', + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + logError(message: string): LoggerPromise { + return new LoggerPromise(this._logErrorInternal(message)); } - /** Adds a .NET tool resource */ + /** Logs a debug message */ /** @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', + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', rpcArgs ); - return new DotnetToolResource(result, this._client); + return this; } - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._logDebugInternal(message)); } - /** Adds an executable resource */ + /** Logs a message with specified level */ /** @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', + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', rpcArgs ); - return new ExecutableResource(result, this._client); + return this; } - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._logInternal(level, message)); } - /** Adds an external service resource */ - /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); } - /** Adds an external service with a URI */ - /** @internal */ - async _addExternalService2Internal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceUri', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); } - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService2Internal(name, uri)); + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); } - /** Adds an external service with a parameter URL */ - /** @internal */ - async _addExternalService1Internal(name: string, urlParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, urlParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceParameter', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); } - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService1Internal(name, urlParameter)); + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); } - /** Adds a parameter resource */ +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', rpcArgs ); - return new ParameterResource(result, this._client); + return new Logger(result, this._client); } - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); } - /** Adds a parameter with a default value */ - /** @internal */ - async _addParameter1Internal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameterWithValue', - rpcArgs - ); - return new ParameterResource(result, this._client); +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - const publishValueAsDefault = options?.publishValueAsDefault; - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameter1Internal(name, value, publishValueAsDefault, secret)); + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); } - /** Adds a parameter sourced from configuration */ +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ /** @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', + 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 ParameterResource(result, this._client); + return new ReportingTask(result, this._client); } - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); } - /** Adds a connection string resource */ + /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', + 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 ResourceWithConnectionString(result, this._client); + return new ReportingTask(result, this._client); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); } - /** Adds a .NET project resource */ + /** Logs a plain-text message for the reporting step */ /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', rpcArgs ); - return new ProjectResource(result, this._client); + return this; } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); } - /** Adds a project resource with configuration options */ + /** Logs a Markdown-formatted message for the reporting step */ /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', rpcArgs ); - return new ProjectResource(result, this._client); + return this; } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); } - /** Adds a C# application resource */ + /** Completes the reporting step with plain-text completion text */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + 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 new ProjectResource(result, this._client); + return this; } - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); } - /** Adds a C# application resource with configuration options */ + /** Completes the reporting step with Markdown-formatted completion text */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', + 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 new CSharpAppResource(result, this._client); + return this; } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } - /** Adds an Azure OpenAI resource */ - /** @internal */ - async _addAzureOpenAIInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.CognitiveServices/addAzureOpenAI', - rpcArgs - ); - return new AzureOpenAIResource(result, this._client); +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addAzureOpenAI(name: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._addAzureOpenAIInternal(name)); + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); } - /** Adds an Azure Bicep template resource from a file */ - /** @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 AzureBicepResource(result, this._client); + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - /** @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 AzureBicepResource(result, this._client); + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); } - /** Adds an Azure provisioning resource to the application model */ + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ /** @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 AzureResourceInfrastructure(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', + 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 new AzureProvisioningResource(result, this._client); + return this; } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); } - /** Adds Azure provisioning services to the distributed application builder */ + /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _addAzureProvisioningInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', + 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 new DistributedApplicationBuilder(result, this._client); + return this; } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } - /** Adds the shared Azure environment resource to the application model */ + /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + 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 new AzureEnvironmentResource(result, this._client); + return this; } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } - /** Adds an Azure user-assigned identity resource */ + /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _addAzureUserAssignedIdentityInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + 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 new AzureUserAssignedIdentityResource(result, this._client); + return this; } - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); } - /** Adds a connection string with a reference expression */ - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionString1(name, connectionStringExpression))); + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } - /** Adds a container registry with string endpoint */ - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry1(name, endpoint, options))); - } +} - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); - } +// ============================================================================ +// ServiceProvider +// ============================================================================ - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); - } +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); - } + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); } - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); } - /** Adds an external service with a URI */ - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService2(name, uri))); + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); } - /** Adds an external service with a parameter URL */ - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService1(name, urlParameter))); + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); } - /** Adds a parameter with a default value */ - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter1(name, value, options))); + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); } - /** Adds an Azure OpenAI resource */ - addAzureOpenAI(name: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.addAzureOpenAI(name))); +} + +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); } - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); } } // ============================================================================ -// DistributedApplicationEventing +// UserSecretsManager // ============================================================================ /** - * Type class for DistributedApplicationEventing. + * Type class for UserSecretsManager. */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Invokes the Unsubscribe method */ + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); + } + + /** Saves state to user secrets from a JSON string */ /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; + 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.Eventing/IDistributedApplicationEventing.unsubscribe', + 'Aspire.Hosting/saveStateJson', rpcArgs ); return this; } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + /** @internal */ + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting/getOrSetSecret', + rpcArgs + ); + return this; + } + + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } /** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } @@ -2467,11 +4706,26 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2486,7 +4740,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2529,36 +4783,6 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureBicepResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -2636,6 +4860,86 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -2651,6 +4955,135 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -2700,23 +5133,9 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -2725,28 +5144,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -2755,13 +5161,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -2770,8 +5178,9 @@ export class AzureBicepResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -2871,39 +5285,94 @@ export class AzureBicepResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Cognitive Services roles to a resource */ + withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); } - /** Assigns Cognitive Services roles to a resource */ - withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); } /** Publishes an Azure resource to the manifest as a connection string */ @@ -2926,29 +5395,19 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -3173,11 +5632,26 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3192,7 +5666,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3235,36 +5709,6 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -3342,6 +5786,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -3464,6 +5988,11 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3484,16 +6013,6 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -3514,6 +6033,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -3620,6 +6159,27 @@ export class AzureOpenAIDeploymentResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AzureOpenAIDeploymentResource.parent', + { context: this._handle } + ); + return new AzureOpenAIResource(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AzureOpenAIDeploymentResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + /** Gets the Name property */ name = { get: async (): Promise => { @@ -3682,7 +6242,7 @@ export class AzureOpenAIDeploymentResource extends ResourceBuilderBase { + 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', @@ -3691,8 +6251,8 @@ export class AzureOpenAIDeploymentResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -3871,11 +6440,26 @@ export class AzureOpenAIDeploymentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureOpenAIDeploymentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureOpenAIDeploymentResource(result, this._client); @@ -3890,7 +6474,7 @@ export class AzureOpenAIDeploymentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureOpenAIDeploymentResource(result, this._client); @@ -3933,36 +6517,6 @@ export class AzureOpenAIDeploymentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureOpenAIDeploymentResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureOpenAIDeploymentResourcePromise { - return new AzureOpenAIDeploymentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureOpenAIDeploymentResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureOpenAIDeploymentResourcePromise { - return new AzureOpenAIDeploymentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -4040,6 +6594,106 @@ export class AzureOpenAIDeploymentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureOpenAIDeploymentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureOpenAIDeploymentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureOpenAIDeploymentResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureOpenAIDeploymentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureOpenAIDeploymentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withPropertiesInternal(configure: (obj: AzureOpenAIDeploymentResource) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { @@ -4107,8 +6761,8 @@ export class AzureOpenAIDeploymentResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureOpenAIDeploymentResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureOpenAIDeploymentResourcePromise { return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -4117,6 +6771,11 @@ export class AzureOpenAIDeploymentResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureOpenAIDeploymentResourcePromise { return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -4162,6 +6821,11 @@ export class AzureOpenAIDeploymentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureOpenAIDeploymentResourcePromise { return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4182,16 +6846,6 @@ export class AzureOpenAIDeploymentResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureOpenAIDeploymentResourcePromise { - return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureOpenAIDeploymentResourcePromise { - return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureOpenAIDeploymentResourcePromise { return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -4207,9 +6861,34 @@ export class AzureOpenAIDeploymentResourcePromise implements PromiseLike obj.withPipelineConfiguration(callback))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureOpenAIDeploymentResourcePromise { + return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } /** Configures properties of an Azure OpenAI deployment */ @@ -4285,7 +6964,7 @@ export class AzureOpenAIResource extends ResourceBuilderBase { + 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', @@ -4294,8 +6973,8 @@ export class AzureOpenAIResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -4474,11 +7162,26 @@ export class AzureOpenAIResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureOpenAIResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureOpenAIResource(result, this._client); @@ -4493,7 +7196,7 @@ export class AzureOpenAIResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureOpenAIResource(result, this._client); @@ -4536,36 +7239,6 @@ export class AzureOpenAIResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureOpenAIResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureOpenAIResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -4643,6 +7316,106 @@ export class AzureOpenAIResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureOpenAIResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureOpenAIResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureOpenAIResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureOpenAIResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureOpenAIResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _addDeploymentInternal(name: string, modelName: string, modelVersion: string): Promise { const rpcArgs: Record = { builder: this._handle, name, modelName, modelVersion }; @@ -4871,23 +7644,9 @@ export class AzureOpenAIResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureOpenAIResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -4896,28 +7655,15 @@ export class AzureOpenAIResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureOpenAIResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -4926,13 +7672,15 @@ export class AzureOpenAIResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -4941,8 +7689,9 @@ export class AzureOpenAIResource extends ResourceBuilderBase obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureOpenAIResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureOpenAIResourcePromise { return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -4987,6 +7736,11 @@ export class AzureOpenAIResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureOpenAIResourcePromise { return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -5032,6 +7786,11 @@ export class AzureOpenAIResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureOpenAIResourcePromise { return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5052,16 +7811,6 @@ export class AzureOpenAIResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureOpenAIResourcePromise { return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -5082,6 +7831,31 @@ export class AzureOpenAIResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Adds an Azure OpenAI deployment resource */ addDeployment(name: string, modelName: string, modelVersion: string): AzureOpenAIDeploymentResourcePromise { return new AzureOpenAIDeploymentResourcePromise(this._promise.then(obj => obj.addDeployment(name, modelName, modelVersion))); @@ -5162,29 +7936,19 @@ export class AzureOpenAIResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureOpenAIResourcePromise { - return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureOpenAIResourcePromise { + return new AzureOpenAIResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -5409,11 +8173,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -5428,7 +8207,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -5471,36 +8250,6 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -5544,38 +8293,118 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureProvisioningResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureProvisioningResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -5722,6 +8551,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -5771,23 +8620,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -5796,28 +8631,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -5826,13 +8648,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -5841,8 +8665,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5942,16 +8772,6 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -5972,6 +8792,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -6022,6 +8862,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -6042,29 +8887,19 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -6289,11 +9124,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -6308,7 +9158,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -6351,36 +9201,6 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -6458,6 +9278,86 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -6671,23 +9571,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -6696,28 +9582,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -6726,13 +9599,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -6741,8 +9616,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6842,16 +9723,6 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -6872,6 +9743,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -6947,29 +9838,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -7035,7 +9916,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -7044,8 +9925,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -7176,7 +10066,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -7206,7 +10096,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -7252,7 +10142,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -7301,11 +10191,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -7320,7 +10225,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -7333,64 +10238,34 @@ export class ConnectionStringResource extends ResourceBuilderBase { - 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 ConnectionStringResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { - const iconVariant = options?.iconVariant; - return new ConnectionStringResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + 'Aspire.Hosting/withIconName', rpcArgs ); return new ConnectionStringResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { + const iconVariant = options?.iconVariant; + return new ConnectionStringResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new ConnectionStringResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ @@ -7470,6 +10345,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -7517,8 +10492,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -7527,6 +10502,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -7597,6 +10577,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -7617,16 +10602,6 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -7647,6 +10622,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -7874,11 +10874,26 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -7893,7 +10908,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -7936,36 +10951,6 @@ export class ContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ContainerRegistryResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -8043,6 +11028,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -8135,6 +11200,11 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -8155,16 +11225,6 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -8185,6 +11245,26 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -8405,7 +11485,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -8414,8 +11494,8 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new ContainerResource(result, this._client); @@ -8434,6 +11514,27 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -8549,73 +11650,23 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -8623,15 +11674,15 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -8649,6 +11700,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -8735,52 +11801,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -9080,7 +12133,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -9110,7 +12163,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -9156,7 +12209,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -9261,7 +12314,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -9288,11 +12341,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -9307,7 +12375,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -9505,6 +12573,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -9554,7 +12722,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ContainerResource(result, this._client); @@ -9647,8 +12815,8 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -9657,6 +12825,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -9697,31 +12870,21 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -9747,21 +12910,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -9907,6 +13065,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9967,6 +13130,31 @@ export class ContainerResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -10112,58 +13300,50 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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 CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironment', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -10174,43 +13354,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -10299,52 +13474,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -10629,7 +13791,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -10659,7 +13821,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -10689,7 +13851,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -10735,7 +13897,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -10840,7 +14002,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -10853,25 +14015,40 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle }; + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withoutHttpsCertificateInternal()); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -10886,7 +14063,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11065,6 +14242,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -11114,7 +14391,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11177,36 +14454,31 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -11232,21 +14504,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -11397,6 +14664,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -11452,6 +14724,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -11739,41 +15036,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -11784,43 +15051,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -11909,52 +15171,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -12254,7 +15503,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -12284,7 +15533,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -12330,7 +15579,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -12435,7 +15684,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -12462,11 +15711,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -12481,7 +15745,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -12660,6 +15924,106 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -12709,7 +16073,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -12814,34 +16178,24 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -12867,21 +16221,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -13027,6 +16376,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -13082,6 +16436,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -13147,6 +16526,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -13214,41 +16658,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -13259,43 +16673,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -13384,52 +16793,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -13729,7 +17125,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13759,7 +17155,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13805,7 +17201,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13910,7 +17306,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13937,11 +17333,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13956,7 +17367,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14077,62 +17488,162 @@ export class ExecutableResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds a pipeline step to the resource */ + 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 ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -14184,7 +17695,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14222,6 +17733,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -14242,31 +17773,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -14292,21 +17813,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -14452,6 +17968,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14507,6 +18028,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -14768,11 +18314,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -14787,7 +18348,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -14830,36 +18391,6 @@ export class ExternalServiceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ExternalServiceResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -14937,6 +18468,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -15034,6 +18645,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15054,16 +18670,6 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -15084,6 +18690,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -15328,11 +18954,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -15347,7 +18988,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -15390,36 +19031,6 @@ export class ParameterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ParameterResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -15497,6 +19108,86 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -15594,6 +19285,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15614,16 +19310,6 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -15644,6 +19330,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -15744,74 +19450,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -15819,15 +19527,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -15845,6 +19553,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -15931,52 +19654,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -16261,7 +19971,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -16291,7 +20001,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -16321,7 +20031,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -16367,7 +20077,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -16472,7 +20182,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -16499,11 +20209,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -16518,7 +20243,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -16697,6 +20422,106 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -16746,7 +20571,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ProjectResource(result, this._client); @@ -16799,29 +20624,29 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -16829,6 +20654,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -16854,21 +20684,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -17019,6 +20844,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -17074,6 +20904,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -17154,23 +21009,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -17179,28 +21020,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -17209,13 +21037,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -17224,8 +21054,9 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -17265,29 +21096,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -17301,11 +21122,41 @@ export class ComputeResource extends ResourceBuilderBase super(handle, 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 ComputeResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ComputeResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + /** @internal */ private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ComputeResource(result, this._client); @@ -17333,6 +21184,16 @@ export class ComputeResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + /** Associates an Azure user-assigned identity with a compute resource */ withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): ComputeResourcePromise { return new ComputeResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); @@ -17353,7 +21214,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -17608,11 +21469,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -17627,7 +21503,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -17670,36 +21546,6 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._excludeFromMcpInternal()); } - /** @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 Resource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 Resource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -17777,6 +21623,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withCognitiveServicesRoleAssignmentsInternal(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -17869,6 +21795,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -17889,16 +21820,6 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -17919,6 +21840,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Cognitive Services roles to a resource */ withCognitiveServicesRoleAssignments(target: AzureOpenAIResource, roles: AzureOpenAIRole[]): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withCognitiveServicesRoleAssignments(target, roles))); @@ -18034,7 +21975,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -18043,8 +21984,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -18080,8 +22050,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -18090,6 +22060,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -18378,6 +22358,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -18445,6 +22445,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -18487,41 +22492,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -18532,43 +22507,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -18602,52 +22572,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -18730,7 +22687,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -18814,31 +22771,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -18849,21 +22796,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -18911,34 +22853,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -18952,7 +22866,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -18982,7 +22896,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -19013,7 +22927,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -19132,7 +23046,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { const error = reason instanceof Error ? reason : new Error(String(reason)); - if (reason instanceof CapabilityError) { + 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) { @@ -19163,8 +23079,12 @@ process.on('unhandledRejection', (reason: unknown) => { }); process.on('uncaughtException', (error: Error) => { - console.error(`\n❌ Uncaught Exception: ${error.message}`); - if (error.stack) { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + if (!(error instanceof AppHostUsageError) && error.stack) { console.error(error.stack); } process.exit(1); @@ -19175,23 +23095,46 @@ process.on('uncaughtException', (error: Error) => { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource', (handle, client) => new AzureEnvironmentResource(handle as AzureEnvironmentResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.CognitiveServices/Aspire.Hosting.ApplicationModel.AzureOpenAIDeploymentResource', (handle, client) => new AzureOpenAIDeploymentResource(handle as AzureOpenAIDeploymentResourceHandle, client)); @@ -19216,6 +23159,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/base.ts index 7778b0f1737..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -43,22 +43,46 @@ export class ReferenceExpression { private readonly _format?: string; private readonly _valueProviders?: unknown[]; + // Conditional mode fields + private readonly _condition?: unknown; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; + private readonly _matchValue?: string; + // Handle mode fields (when wrapping a server-returned handle) private readonly _handle?: Handle; private readonly _client?: AspireClient; constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(handleOrFormat: Handle | string, clientOrValueProviders: AspireClient | unknown[]) { - if (typeof handleOrFormat === 'string') { - this._format = handleOrFormat; - this._valueProviders = clientOrValueProviders as unknown[]; + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression + ) { + if (typeof handleOrFormatOrCondition === 'string') { + this._format = handleOrFormatOrCondition; + this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (handleOrFormatOrCondition instanceof Handle) { + this._handle = handleOrFormatOrCondition; + this._client = clientOrValueProvidersOrMatchValue as AspireClient; } else { - this._handle = handleOrFormat; - this._client = clientOrValueProviders as AspireClient; + this._condition = handleOrFormatOrCondition; + this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + this._whenTrue = whenTrueOrWhenFalse; + this._whenFalse = whenFalse; } } + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return this._condition !== undefined; + } + /** * Creates a reference expression from a tagged template literal. * @@ -82,16 +106,46 @@ export class ReferenceExpression { return new ReferenceExpression(format, valueProviders); } + /** + * Creates a conditional reference expression from its constituent parts. + * + * @param condition - A value provider whose result is compared to matchValue + * @param whenTrue - The expression to use when the condition matches + * @param whenFalse - The expression to use when the condition does not match + * @param matchValue - The value to compare the condition against (defaults to "True") + * @returns A ReferenceExpression instance in conditional mode + */ + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression { + return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + } + /** * Serializes the reference expression for JSON-RPC transport. - * In template-literal mode, uses the $expr format. + * 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[] } } | MarshalledHandle { + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { if (this._handle) { return this._handle.toJSON(); } + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(this._condition), + whenTrue: this._whenTrue!.toJSON(), + whenFalse: this._whenFalse!.toJSON(), + matchValue: this._matchValue! + } + }; + } + return { $expr: { format: this._format!, @@ -100,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -107,10 +185,17 @@ export class ReferenceExpression { if (this._handle) { return `ReferenceExpression(handle)`; } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } return `ReferenceExpression(${this._format})`; } } +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. @@ -136,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -307,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -466,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/transport.ts index 7bddd74beff..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -213,6 +354,76 @@ export class CapabilityError extends Error { } } +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + } +} + +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 // ============================================================================ @@ -324,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -346,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -361,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -381,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -411,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -422,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -432,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + 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; - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + let settled = false; - this.socket = net.createConnection(pipePath); + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -475,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -533,39 +935,66 @@ export class AspireClient { throw new Error('Not connected to AppHost'); } - // 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++; + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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++; - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + 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 { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/apphost.ts index 79d767a43a0..1cebe62d6dd 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/apphost.ts @@ -6,9 +6,12 @@ import { AzureOpenAIRole, createBuilder } from './.modules/aspire.js'; const builder = await createBuilder(); const openai = await builder.addAzureOpenAI('openai'); -await openai.addDeployment('chat', 'gpt-4o-mini', '2024-07-18'); +const chat = await openai.addDeployment('chat', 'gpt-4o-mini', '2024-07-18'); const api = await builder.addContainer('api', 'redis:latest'); await api.withCognitiveServicesRoleAssignments(openai, [AzureOpenAIRole.CognitiveServicesOpenAIUser]); +const _deploymentParent = await chat.parent.get(); +const _deploymentConnectionString = await chat.connectionStringExpression.get(); + await builder.build().run(); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..c02330b2893 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.CognitiveServices/ValidationAppHost/aspire.config.json @@ -0,0 +1,9 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "packages": { + "Aspire.Hosting.Azure.CognitiveServices": "" + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.aspire/settings.json deleted file mode 100644 index 5707c55c632..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.aspire/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", - "packages": { - "Aspire.Hosting.Azure.EventHubs": "" - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/.codegen-hash index cb9c4c90b2d..b4f2f9f071c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -D273E1CAF3A711B421811D804D2163791A6DFB5DCBF0B012BC3F22C5CFDB5211 \ No newline at end of file +5030A5600305B9E7F550A9C5D52ECD21103425725A74A0DACB820A5B79CD9C8B \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/aspire.ts index 6935824ecdb..c4e35a14ff0 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/aspire.ts @@ -8,6 +8,8 @@ import { AspireClient as AspireClientRpc, Handle, MarshalledHandle, + AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -89,9 +91,21 @@ type BicepOutputReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Az /** Handle to IAzureKeyVaultSecretReference */ type IAzureKeyVaultSecretReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultSecretReference'>; +/** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -101,6 +115,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -125,6 +142,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -155,15 +175,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -188,18 +220,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -212,12 +259,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -296,6 +349,7 @@ export enum EndpointProperty { Scheme = "Scheme", TargetPort = "TargetPort", HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", } /** Enum type for IconVariant */ @@ -371,6 +425,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -401,6 +461,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -435,7 +516,7 @@ export interface AddConsumerGroupOptions { groupName?: string; } -export interface AddContainerRegistry1Options { +export interface AddContainerRegistryFromStringOptions { repository?: string; } @@ -456,16 +537,21 @@ export interface AddHubOptions { hubName?: string; } -export interface AddParameter1Options { - publishValueAsDefault?: boolean; +export interface AddParameterFromConfigurationOptions { secret?: boolean; } -export interface AddParameterFromConfigurationOptions { +export interface AddParameterOptions { secret?: boolean; } -export interface AddParameterOptions { +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; secret?: boolean; } @@ -481,8 +567,54 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; } export interface RunAsEmulator1Options { @@ -493,14 +625,34 @@ export interface RunAsEmulatorOptions { configureContainer?: (obj: AzureEventHubsEmulatorResource) => Promise; } +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + export interface RunOptions { - cancellationToken?: AbortSignal; + 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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithApiVersionCheckOptions { enable?: boolean; } @@ -513,6 +665,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDataBindMountOptions { path?: string; isReadOnly?: boolean; @@ -616,6 +774,7 @@ export interface WithPipelineStepFactoryOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -635,6 +794,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -676,6 +872,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -750,11 +1020,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -769,6 +1040,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -786,9 +1116,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -862,6 +1192,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -884,6 +1225,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -897,6 +1302,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -963,6 +1379,16 @@ export class EndpointReference { }, }; + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { @@ -1017,13 +1443,22 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs ); } + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + 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 + ); + } + } /** @@ -1044,6 +1479,11 @@ export class EndpointReferencePromise implements PromiseLike return this._promise.then(obj => obj.getValueAsync(options)); } + /** 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 { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + } // ============================================================================ @@ -1121,11 +1561,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1155,6 +1618,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1173,16 +1647,17 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; @@ -1190,35 +1665,127 @@ export class ExecuteCommandContext { } // ============================================================================ -// PipelineConfigurationContext +// InitializeResourceEvent // ============================================================================ /** - * Type class for PipelineConfigurationContext. + * Type class for InitializeResourceEvent. */ -export class PipelineConfigurationContext { - constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Steps property */ - steps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, - set: async (value: PipelineStep[]): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', - { context: this._handle, value } - ); - } }; - /** Gets pipeline steps with the specified tag */ + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + { context: this._handle } + ); + }, + set: async (value: PipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } + ); + } + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; return await this._client.invokeCapability( @@ -1249,6 +1816,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1336,6 +1990,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1406,6 +2071,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1417,18 +2115,159 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; } +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + +} + // ============================================================================ // ProjectResourceOptions // ============================================================================ @@ -1611,86 +2450,381 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new ServiceProvider(handle, this._client); }, }; } // ============================================================================ -// DistributedApplicationBuilder +// ResourceLoggerService // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for ResourceLoggerService. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, + /** Completes the log stream for a resource */ + /** @internal */ + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + } + + /** Completes the log stream by resource name */ + /** @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 ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); + } + + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ + /** @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 ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + } + + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** Waits for all dependencies of a resource to be ready */ + /** @internal */ + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + } + + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ + /** @internal */ + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, }; - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); }, }; @@ -1698,674 +2832,1779 @@ export class DistributedApplicationBuilder { executionContext = { get: async (): Promise => { const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', { context: this._handle } ); return new DistributedApplicationExecutionContext(handle, this._client); }, }; - /** Builds the distributed application */ - /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', rpcArgs ); - return new DistributedApplication(result, this._client); } - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); } - /** Adds a connection string with a reference expression */ - /** @internal */ - async _addConnectionString1Internal(name: string, connectionStringExpression: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringExpression', + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionString1Internal(name, connectionStringExpression)); + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); } - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', + /** Checks whether a configuration section exists */ + async exists(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/exists', rpcArgs ); - return new ConnectionStringResource(result, this._client); + } + +} + +/** + * Thenable wrapper for Configuration that enables fluent chaining. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); } addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); } - /** Adds a container registry resource */ - /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { - 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 ContainerRegistryResource(result, this._client); + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + 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 ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @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 ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @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 DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @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 ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @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 ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds an Azure Event Hubs namespace resource */ + /** @internal */ + async _addAzureEventHubsInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.EventHubs/addAzureEventHubs', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + addAzureEventHubs(name: string): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._addAzureEventHubsInternal(name)); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + + /** Adds an Azure Storage resource */ + /** @internal */ + async _addAzureStorageInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addAzureStorage', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + addAzureStorage(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._addAzureStorageInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds an Azure Event Hubs namespace resource */ + addAzureEventHubs(name: string): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.addAzureEventHubs(name))); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + + /** Adds an Azure Storage resource */ + addAzureStorage(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.addAzureStorage(name))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', + rpcArgs + ); + } + + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', + rpcArgs + ); + } + + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); + } + + /** Checks if the environment matches the specified name */ + 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. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); + } + + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); + } + + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); } - /** Adds a container registry with string endpoint */ +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ /** @internal */ - async _addContainerRegistry1Internal(name: string, endpoint: string, repository?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistryFromString', + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', rpcArgs ); - return new ContainerRegistryResource(result, this._client); + return this; } - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistry1Internal(name, endpoint, repository)); + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._logInformationInternal(message)); } - /** Adds a container resource */ + /** Logs a warning message */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._logWarningInternal(message)); } - /** Adds a container resource built from a Dockerfile */ + /** Logs an error message */ /** @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', + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + logError(message: string): LoggerPromise { + return new LoggerPromise(this._logErrorInternal(message)); } - /** Adds a .NET tool resource */ + /** Logs a debug message */ /** @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', + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', rpcArgs ); - return new DotnetToolResource(result, this._client); + return this; } - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._logDebugInternal(message)); } - /** Adds an executable resource */ + /** Logs a message with specified level */ /** @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', + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', rpcArgs ); - return new ExecutableResource(result, this._client); + return this; } - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._logInternal(level, message)); } - /** Adds an external service resource */ - /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); } - /** Adds an external service with a URI */ - /** @internal */ - async _addExternalService2Internal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceUri', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); } - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService2Internal(name, uri)); + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); } - /** Adds an external service with a parameter URL */ - /** @internal */ - async _addExternalService1Internal(name: string, urlParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, urlParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceParameter', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); } - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService1Internal(name, urlParameter)); + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); } - /** Adds a parameter resource */ +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', rpcArgs ); - return new ParameterResource(result, this._client); + return new Logger(result, this._client); } - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); } - /** Adds a parameter with a default value */ - /** @internal */ - async _addParameter1Internal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameterWithValue', - rpcArgs - ); - return new ParameterResource(result, this._client); +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - const publishValueAsDefault = options?.publishValueAsDefault; - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameter1Internal(name, value, publishValueAsDefault, secret)); + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); } - /** Adds a parameter sourced from configuration */ +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ /** @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', + 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 ParameterResource(result, this._client); + return new ReportingTask(result, this._client); } - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); } - /** Adds a connection string resource */ + /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', + 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 ResourceWithConnectionString(result, this._client); + return new ReportingTask(result, this._client); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); } - /** Adds a .NET project resource */ + /** Logs a plain-text message for the reporting step */ /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', rpcArgs ); - return new ProjectResource(result, this._client); + return this; } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); } - /** Adds a project resource with configuration options */ + /** Logs a Markdown-formatted message for the reporting step */ /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', rpcArgs ); - return new ProjectResource(result, this._client); + return this; } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); } - /** Adds a C# application resource */ + /** Completes the reporting step with plain-text completion text */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + 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 new ProjectResource(result, this._client); + return this; } - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); } - /** Adds a C# application resource with configuration options */ + /** Completes the reporting step with Markdown-formatted completion text */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', + 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 new CSharpAppResource(result, this._client); + return this; } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } - /** Adds an Azure Event Hubs namespace resource */ - /** @internal */ - async _addAzureEventHubsInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.EventHubs/addAzureEventHubs', - rpcArgs - ); - return new AzureEventHubsResource(result, this._client); - } +} - addAzureEventHubs(name: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._addAzureEventHubsInternal(name)); +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds an Azure Bicep template resource from a file */ - /** @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 AzureBicepResource(result, this._client); + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - /** @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 AzureBicepResource(result, this._client); + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); } - /** Adds an Azure provisioning resource to the application model */ - /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); } - /** Adds Azure provisioning services to the distributed application builder */ +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ /** @internal */ - async _addAzureProvisioningInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', + 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 new DistributedApplicationBuilder(result, this._client); + return this; } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); } - /** Adds the shared Azure environment resource to the application model */ + /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + 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 new AzureEnvironmentResource(result, this._client); + return this; } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } - /** Adds an Azure user-assigned identity resource */ + /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _addAzureUserAssignedIdentityInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + 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 new AzureUserAssignedIdentityResource(result, this._client); + return this; } - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } - /** Adds an Azure Storage resource */ + /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _addAzureStorageInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addAzureStorage', + 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 new AzureStorageResource(result, this._client); + return this; } - addAzureStorage(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._addAzureStorageInternal(name)); + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); } - /** Adds a connection string with a reference expression */ - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionString1(name, connectionStringExpression))); + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } - /** Adds a container registry with string endpoint */ - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry1(name, endpoint, options))); - } +} - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); - } +// ============================================================================ +// ServiceProvider +// ============================================================================ - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); - } +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); - } + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); } - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); } - /** Adds an external service with a URI */ - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService2(name, uri))); + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); } - /** Adds an external service with a parameter URL */ - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService1(name, urlParameter))); + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); } - /** Adds a parameter with a default value */ - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter1(name, value, options))); + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); } - /** Adds an Azure Event Hubs namespace resource */ - addAzureEventHubs(name: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.addAzureEventHubs(name))); - } +} - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); } - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); } - /** Adds an Azure Storage resource */ - addAzureStorage(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.addAzureStorage(name))); + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); } } // ============================================================================ -// DistributedApplicationEventing +// UserSecretsManager // ============================================================================ /** - * Type class for DistributedApplicationEventing. + * Type class for UserSecretsManager. */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Invokes the Unsubscribe method */ + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); + } + + /** Saves state to user secrets from a JSON string */ /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; + 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.Eventing/IDistributedApplicationEventing.unsubscribe', + 'Aspire.Hosting/saveStateJson', rpcArgs ); return this; } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + /** @internal */ + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting/getOrSetSecret', + rpcArgs + ); + return this; + } + + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } /** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } @@ -2590,11 +4829,26 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2609,7 +4863,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2652,36 +4906,6 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureBicepResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -2759,6 +4983,86 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -2774,6 +5078,135 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -2823,23 +5256,9 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -2848,28 +5267,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -2878,13 +5284,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -2893,8 +5301,9 @@ export class AzureBicepResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3009,39 +5423,94 @@ export class AzureBicepResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Event Hubs roles to a resource */ + withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); } - /** Assigns Event Hubs roles to a resource */ - withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); } /** Publishes an Azure resource to the manifest as a connection string */ @@ -3064,29 +5533,19 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Assigns Azure Storage roles to a resource */ @@ -3157,7 +5616,7 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + 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', @@ -3166,8 +5625,8 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -3346,11 +5814,26 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBlobStorageContainerResource(result, this._client); @@ -3365,7 +5848,7 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBlobStorageContainerResource(result, this._client); @@ -3408,36 +5891,6 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureBlobStorageContainerResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureBlobStorageContainerResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -3515,6 +5968,106 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -3577,8 +6130,8 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageContainerResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -3587,6 +6140,11 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -3632,6 +6190,11 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3652,16 +6215,6 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -3682,6 +6235,31 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -3755,7 +6333,7 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { + 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', @@ -3764,8 +6342,8 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -3944,11 +6531,26 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBlobStorageResource(result, this._client); @@ -3963,7 +6565,7 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBlobStorageResource(result, this._client); @@ -4006,36 +6608,6 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureBlobStorageResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -4113,6 +6685,106 @@ export class AzureBlobStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -4175,8 +6847,8 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -4185,6 +6857,11 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -4230,6 +6907,11 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4250,16 +6932,6 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -4280,6 +6952,31 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -4353,7 +7050,7 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + 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', @@ -4362,8 +7059,8 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyInternal(name, value)); } @@ -4382,6 +7079,15 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyValueInternal(name, value)); } + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -4542,11 +7248,26 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureDataLakeStorageFileSystemResource(result, this._client); @@ -4561,7 +7282,7 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureDataLakeStorageFileSystemResource(result, this._client); @@ -4604,36 +7325,6 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResourcePromise(this._excludeFromMcpInternal()); } - /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -4711,6 +7402,106 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -4773,8 +7564,8 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -4783,6 +7574,11 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -4828,6 +7624,11 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4848,16 +7649,6 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -4878,6 +7669,31 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -4951,7 +7767,7 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + 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', @@ -4960,8 +7776,8 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -5140,11 +7965,26 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); @@ -5159,7 +7999,7 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); @@ -5203,110 +8043,180 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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 PipelineStepContext(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/withRemoteImageName', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureDataLakeStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onConnectionStringAvailable', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureDataLakeStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -5371,8 +8281,8 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -5381,6 +8291,11 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -5426,6 +8341,11 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5446,16 +8366,6 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -5476,6 +8386,31 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -5708,11 +8643,26 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -5727,7 +8677,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -5770,36 +8720,6 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -5877,6 +8797,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -6014,6 +9014,11 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6034,16 +9039,6 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -6064,6 +9059,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -6147,7 +9162,7 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { + 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', @@ -6156,8 +9171,8 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -6336,11 +9360,26 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubConsumerGroupResource(result, this._client); @@ -6355,7 +9394,7 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubConsumerGroupResource(result, this._client); @@ -6398,36 +9437,6 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEventHubConsumerGroupResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEventHubConsumerGroupResourcePromise { - return new AzureEventHubConsumerGroupResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEventHubConsumerGroupResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEventHubConsumerGroupResourcePromise { - return new AzureEventHubConsumerGroupResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -6485,24 +9494,124 @@ export class AzureEventHubConsumerGroupResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEventHubConsumerGroupResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEventHubConsumerGroupResourcePromise { - return new AzureEventHubConsumerGroupResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onInitializeResourceInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEventHubConsumerGroupResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -6567,8 +9676,8 @@ export class AzureEventHubConsumerGroupResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureEventHubConsumerGroupResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureEventHubConsumerGroupResourcePromise { return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -6577,6 +9686,11 @@ export class AzureEventHubConsumerGroupResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEventHubConsumerGroupResourcePromise { return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -6622,6 +9736,11 @@ export class AzureEventHubConsumerGroupResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEventHubConsumerGroupResourcePromise { return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6642,16 +9761,6 @@ export class AzureEventHubConsumerGroupResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEventHubConsumerGroupResourcePromise { - return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEventHubConsumerGroupResourcePromise { - return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEventHubConsumerGroupResourcePromise { return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -6672,6 +9781,31 @@ export class AzureEventHubConsumerGroupResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubConsumerGroupResourcePromise { + return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureEventHubConsumerGroupResourcePromise { return new AzureEventHubConsumerGroupResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -6725,6 +9859,27 @@ export class AzureEventHubResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureEventHubResource.parent', + { context: this._handle } + ); + return new AzureEventHubsResource(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureEventHubResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + /** Gets the Name property */ name = { get: async (): Promise => { @@ -6787,7 +9942,7 @@ export class AzureEventHubResource extends ResourceBuilderBase { + 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', @@ -6796,8 +9951,8 @@ export class AzureEventHubResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -6976,11 +10140,26 @@ export class AzureEventHubResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEventHubResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubResource(result, this._client); @@ -6995,7 +10174,7 @@ export class AzureEventHubResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubResource(result, this._client); @@ -7038,36 +10217,6 @@ export class AzureEventHubResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEventHubResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEventHubResourcePromise { - return new AzureEventHubResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEventHubResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEventHubResourcePromise { - return new AzureEventHubResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -7145,6 +10294,106 @@ export class AzureEventHubResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEventHubResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEventHubResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureEventHubResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEventHubResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEventHubResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withPropertiesInternal(configure: (obj: AzureEventHubResource) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { @@ -7244,8 +10493,8 @@ export class AzureEventHubResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureEventHubResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -7254,6 +10503,11 @@ export class AzureEventHubResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -7299,6 +10553,11 @@ export class AzureEventHubResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -7319,16 +10578,6 @@ export class AzureEventHubResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEventHubResourcePromise { - return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEventHubResourcePromise { - return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -7349,6 +10598,31 @@ export class AzureEventHubResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubResourcePromise { + return new AzureEventHubResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Configures properties of an Azure Event Hub */ withProperties(configure: (obj: AzureEventHubResource) => Promise): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.withProperties(configure))); @@ -7584,7 +10858,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -7593,8 +10867,8 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -7613,6 +10887,27 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { + 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 AzureEventHubsEmulatorResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureEventHubsEmulatorResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new AzureEventHubsEmulatorResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -7744,41 +11039,11 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureEventHubsEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new AzureEventHubsEmulatorResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -7789,43 +11054,38 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase Promise): AzureEventHubsEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -7914,52 +11174,39 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureEventHubsEmulatorResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzureEventHubsEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new AzureEventHubsEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureEventHubsEmulatorResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzureEventHubsEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -8259,7 +11506,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8289,7 +11536,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8335,7 +11582,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8440,7 +11687,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8467,11 +11714,26 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEventHubsEmulatorResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8486,7 +11748,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8684,6 +11946,106 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEventHubsEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withHostPortInternal(port?: number): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -8765,7 +12127,7 @@ export class AzureEventHubsEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new AzureEventHubsEmulatorResource(result, this._client); @@ -8873,8 +12235,8 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureEventHubsEmulatorResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -8883,6 +12245,11 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -8923,31 +12290,21 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -8973,21 +12330,16 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureEventHubsEmulatorResourcePromise { - return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -9133,6 +12485,11 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9193,6 +12550,31 @@ export class AzureEventHubsEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsEmulatorResourcePromise { + return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets the host port for the Event Hubs emulator endpoint */ withHostPort(options?: WithHostPortOptions): AzureEventHubsEmulatorResourcePromise { return new AzureEventHubsEmulatorResourcePromise(this._promise.then(obj => obj.withHostPort(options))); @@ -9310,7 +12692,7 @@ export class AzureEventHubsResource extends ResourceBuilderBase { + 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', @@ -9319,8 +12701,8 @@ export class AzureEventHubsResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -9660,11 +13051,26 @@ export class AzureEventHubsResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEventHubsResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEventHubsResource(result, this._client); @@ -9679,7 +13085,7 @@ export class AzureEventHubsResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEventHubsResource(result, this._client); @@ -9751,36 +13157,6 @@ export class AzureEventHubsResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEventHubsResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEventHubsResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -9858,6 +13234,126 @@ export class AzureEventHubsResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEventHubsResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _addHubInternal(name: string, hubName?: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -10110,23 +13606,9 @@ export class AzureEventHubsResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureEventHubsResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -10135,28 +13617,15 @@ export class AzureEventHubsResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureEventHubsResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -10165,13 +13634,15 @@ export class AzureEventHubsResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -10180,8 +13651,9 @@ export class AzureEventHubsResource extends ResourceBuilderBase obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureEventHubsResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureEventHubsResourcePromise { return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -10246,6 +13718,11 @@ export class AzureEventHubsResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): AzureEventHubsResourcePromise { return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -10331,6 +13808,11 @@ export class AzureEventHubsResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEventHubsResourcePromise { return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -10351,19 +13833,9 @@ export class AzureEventHubsResourcePromise implements PromiseLike obj.withHttpProbe(probeType, options))); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ @@ -10386,6 +13858,36 @@ export class AzureEventHubsResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Adds an Azure Event Hub resource */ addHub(name: string, options?: AddHubOptions): AzureEventHubResourcePromise { return new AzureEventHubResourcePromise(this._promise.then(obj => obj.addHub(name, options))); @@ -10471,29 +13973,19 @@ export class AzureEventHubsResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureEventHubsResourcePromise { - return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureEventHubsResourcePromise { + return new AzureEventHubsResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Assigns Azure Storage roles to a resource */ @@ -10723,11 +14215,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -10742,7 +14249,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -10785,36 +14292,6 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -10892,6 +14369,86 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -11036,6 +14593,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -11085,23 +14662,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -11110,28 +14673,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -11140,13 +14690,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -11155,8 +14707,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -11271,16 +14829,6 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -11301,6 +14849,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -11351,6 +14919,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -11371,29 +14944,19 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Assigns Azure Storage roles to a resource */ @@ -11464,7 +15027,7 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + 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', @@ -11473,8 +15036,8 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -11653,11 +15225,26 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); @@ -11672,7 +15259,7 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); @@ -11716,110 +15303,180 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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 PipelineStepContext(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageQueueResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureQueueStorageQueueResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/onResourceStopped', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onConnectionStringAvailable', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageQueueResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureQueueStorageQueueResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -11884,8 +15541,8 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageQueueResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -11894,6 +15551,11 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -11939,6 +15601,11 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -11959,16 +15626,6 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -11989,6 +15646,31 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -12062,7 +15744,7 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { + 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', @@ -12071,8 +15753,8 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -12251,11 +15942,26 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureQueueStorageResource(result, this._client); @@ -12270,7 +15976,7 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureQueueStorageResource(result, this._client); @@ -12313,36 +16019,6 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureQueueStorageResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureQueueStorageResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -12420,6 +16096,106 @@ export class AzureQueueStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -12482,8 +16258,8 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -12492,6 +16268,11 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -12537,6 +16318,11 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -12557,16 +16343,6 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -12587,6 +16363,31 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -12812,7 +16613,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -12821,8 +16622,8 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -12841,6 +16642,27 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + 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 AzureStorageEmulatorResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureStorageEmulatorResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new AzureStorageEmulatorResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -12940,89 +16762,39 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishAsConnectionString', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Publishes the resource as a connection string */ - publishAsConnectionString(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._publishAsConnectionStringInternal()); - } - - /** @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 AzureStorageEmulatorResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageEmulatorResourcePromise { - const helpLink = options?.helpLink; - return new AzureStorageEmulatorResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageEmulatorResourcePromise { + const helpLink = options?.helpLink; + return new AzureStorageEmulatorResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -13030,15 +16802,15 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -13056,6 +16828,21 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -13142,52 +16929,39 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzureStorageEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzureStorageEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -13487,7 +17261,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13517,7 +17291,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13563,7 +17337,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13668,7 +17442,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13695,11 +17469,26 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13714,7 +17503,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -13912,6 +17701,106 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -13961,7 +17850,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -14169,8 +18058,8 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -14179,6 +18068,11 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -14219,31 +18113,21 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -14269,21 +18153,16 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -14429,6 +18308,11 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14489,6 +18373,31 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -14946,11 +18855,26 @@ export class AzureStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureStorageResource(result, this._client); @@ -14965,7 +18889,7 @@ export class AzureStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureStorageResource(result, this._client); @@ -15037,36 +18961,6 @@ export class AzureStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureStorageResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureStorageResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -15144,6 +19038,106 @@ export class AzureStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -15357,23 +19351,9 @@ export class AzureStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureStorageResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -15382,28 +19362,15 @@ export class AzureStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureStorageResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -15412,13 +19379,15 @@ export class AzureStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -15427,8 +19396,9 @@ export class AzureStorageResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureStorageResourcePromise { return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15726,16 +19701,6 @@ export class AzureStorageResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageResourcePromise { return new AzureStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -15756,6 +19721,31 @@ export class AzureStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureStorageResourcePromise { return new AzureStorageResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -15831,29 +19821,19 @@ export class AzureStorageResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures the Azure Storage resource to be emulated using Azurite */ @@ -15964,7 +19944,7 @@ export class AzureTableStorageResource extends ResourceBuilderBase { + 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', @@ -15973,8 +19953,8 @@ export class AzureTableStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -16153,11 +20142,26 @@ export class AzureTableStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureTableStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureTableStorageResource(result, this._client); @@ -16172,7 +20176,7 @@ export class AzureTableStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureTableStorageResource(result, this._client); @@ -16215,36 +20219,6 @@ export class AzureTableStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureTableStorageResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureTableStorageResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -16322,6 +20296,106 @@ export class AzureTableStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -16384,8 +20458,8 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureTableStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -16394,6 +20468,11 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -16439,6 +20518,11 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16459,16 +20543,6 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -16489,6 +20563,31 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -16721,11 +20820,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -16740,7 +20854,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -16784,110 +20898,160 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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 PipelineStepContext(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/withRemoteImageName', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a pipeline step to the resource */ + 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 AzureUserAssignedIdentityResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onResourceStopped', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 AzureUserAssignedIdentityResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -17103,23 +21267,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -17128,28 +21278,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -17158,13 +21295,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -17173,8 +21312,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -17289,16 +21434,6 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -17319,6 +21454,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -17394,29 +21549,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Assigns Azure Storage roles to a resource */ @@ -17487,7 +21632,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -17496,8 +21641,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -17628,7 +21782,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17658,7 +21812,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17704,7 +21858,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17753,11 +21907,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17772,7 +21941,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -17815,36 +21984,6 @@ export class ConnectionStringResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ConnectionStringResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -17922,6 +22061,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -17984,8 +22223,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -17994,6 +22233,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -18064,6 +22308,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18084,16 +22333,6 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -18114,6 +22353,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -18347,95 +22611,80 @@ export class ContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - const iconVariant = options?.iconVariant; - return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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/withRemoteImageName', + 'Aspire.Hosting/withIconName', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ @@ -18515,6 +22764,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -18582,130 +22911,399 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withUrlsCallback(callback))); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Event Hubs roles to a resource */ + withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export class ContainerResource extends ResourceBuilderBase { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageTagInternal(tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromise(this._withImageInternal(image, tag)); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** @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 ContainerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageSHA256Internal(sha256)); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** @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 ContainerResource(result, this._client); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** @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 ContainerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._withLifetimeInternal(lifetime)); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** @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 ContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsContainerInternal()); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** @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 ContainerResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** @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 ContainerResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Assigns Event Hubs roles to a resource */ - withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** @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 ContainerResource(result, this._client); } -} - -// ============================================================================ -// ContainerResource -// ============================================================================ - -export class ContainerResource extends ResourceBuilderBase { - constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + 'Aspire.Hosting/withEndpointProxySupport', rpcArgs ); return new ContainerResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } /** @internal */ @@ -18727,6 +23325,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -18777,58 +23390,43 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -18839,43 +23437,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -18964,52 +23557,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -19309,7 +23889,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -19339,7 +23919,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -19385,7 +23965,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -19490,7 +24070,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -19517,11 +24097,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -19536,7 +24131,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -19706,6 +24301,25 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -19715,6 +24329,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -19764,7 +24478,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ContainerResource(result, this._client); @@ -19812,11 +24526,96 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -19832,36 +24631,31 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -19887,21 +24681,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -20047,6 +24836,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -20097,11 +24891,41 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -20252,58 +25076,50 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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 CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironment', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -20314,43 +25130,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -20439,52 +25250,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -20769,7 +25567,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20799,7 +25597,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20829,7 +25627,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20875,7 +25673,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -20980,7 +25778,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -21007,11 +25805,26 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -21026,7 +25839,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -21205,6 +26018,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -21254,7 +26167,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -21332,36 +26245,31 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -21387,21 +26295,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -21552,6 +26455,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -21607,6 +26515,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -21899,41 +26832,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -21944,43 +26847,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -22069,52 +26967,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -22414,7 +27299,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22444,7 +27329,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22490,7 +27375,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22595,7 +27480,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22622,11 +27507,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22641,7 +27541,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22806,18 +27706,118 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -22869,7 +27869,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -22992,31 +27992,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -23042,21 +28032,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -23202,6 +28187,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -23257,6 +28247,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -23327,6 +28342,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -23394,41 +28474,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -23439,43 +28489,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -23564,52 +28609,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -23909,7 +28941,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23939,7 +28971,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -23985,7 +29017,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -24090,7 +29122,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -24117,11 +29149,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -24136,7 +29183,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -24267,52 +29314,152 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -24364,7 +29511,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ExecutableResource(result, this._client); @@ -24417,6 +29564,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -24437,31 +29604,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -24487,21 +29644,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -24647,6 +29799,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -24702,6 +29859,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -24968,11 +30150,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -24987,7 +30184,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -25030,36 +30227,6 @@ export class ExternalServiceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ExternalServiceResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -25137,6 +30304,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -25249,6 +30496,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -25269,16 +30521,6 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -25299,6 +30541,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -25548,11 +30810,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -25567,7 +30844,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -25610,36 +30887,6 @@ export class ParameterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ParameterResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -25717,6 +30964,86 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -25829,6 +31156,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -25849,16 +31181,6 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -25879,6 +31201,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -25984,74 +31326,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -26059,15 +31403,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -26085,6 +31429,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -26171,52 +31530,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -26501,7 +31847,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -26531,7 +31877,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -26561,7 +31907,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -26607,7 +31953,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -26712,7 +32058,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -26739,11 +32085,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -26758,7 +32119,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -26937,6 +32298,106 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -26986,7 +32447,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ProjectResource(result, this._client); @@ -27054,29 +32515,29 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -27084,6 +32545,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -27109,21 +32575,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -27274,6 +32735,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -27329,6 +32795,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -27414,23 +32905,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -27439,28 +32916,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -27469,13 +32933,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -27484,8 +32950,9 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -27525,29 +32992,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -27561,11 +33018,41 @@ export class ComputeResource extends ResourceBuilderBase super(handle, 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 ComputeResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ComputeResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + /** @internal */ private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ComputeResource(result, this._client); @@ -27593,6 +33080,16 @@ export class ComputeResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + /** Associates an Azure user-assigned identity with a compute resource */ withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): ComputeResourcePromise { return new ComputeResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); @@ -27613,7 +33110,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -27868,11 +33365,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -27887,7 +33399,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -27930,36 +33442,6 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._excludeFromMcpInternal()); } - /** @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 Resource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 Resource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -28037,6 +33519,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEventHubsRoleAssignmentsInternal(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -28144,6 +33706,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -28164,16 +33731,6 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -28194,6 +33751,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Event Hubs roles to a resource */ withEventHubsRoleAssignments(target: AzureEventHubsResource, roles: AzureEventHubsRole[]): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withEventHubsRoleAssignments(target, roles))); @@ -28314,7 +33891,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -28323,8 +33900,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -28360,8 +33966,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -28370,6 +33976,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -28658,6 +34274,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -28725,6 +34361,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -28767,41 +34408,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -28812,43 +34423,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -28882,52 +34488,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -29010,7 +34603,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -29094,31 +34687,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -29129,21 +34712,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -29191,34 +34769,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -29232,7 +34782,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -29262,7 +34812,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -29293,7 +34843,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -29412,7 +34962,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { const error = reason instanceof Error ? reason : new Error(String(reason)); - if (reason instanceof CapabilityError) { + 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) { @@ -29443,8 +34995,12 @@ process.on('unhandledRejection', (reason: unknown) => { }); process.on('uncaughtException', (error: Error) => { - console.error(`\n❌ Uncaught Exception: ${error.message}`); - if (error.stack) { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + if (!(error instanceof AppHostUsageError) && error.stack) { console.error(error.stack); } process.exit(1); @@ -29455,23 +35011,46 @@ process.on('uncaughtException', (error: Error) => { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureBlobStorageContainerResource', (handle, client) => new AzureBlobStorageContainerResource(handle as AzureBlobStorageContainerResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureBlobStorageResource', (handle, client) => new AzureBlobStorageResource(handle as AzureBlobStorageResourceHandle, client)); @@ -29507,6 +35086,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/base.ts index 7778b0f1737..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -43,22 +43,46 @@ export class ReferenceExpression { private readonly _format?: string; private readonly _valueProviders?: unknown[]; + // Conditional mode fields + private readonly _condition?: unknown; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; + private readonly _matchValue?: string; + // Handle mode fields (when wrapping a server-returned handle) private readonly _handle?: Handle; private readonly _client?: AspireClient; constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(handleOrFormat: Handle | string, clientOrValueProviders: AspireClient | unknown[]) { - if (typeof handleOrFormat === 'string') { - this._format = handleOrFormat; - this._valueProviders = clientOrValueProviders as unknown[]; + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression + ) { + if (typeof handleOrFormatOrCondition === 'string') { + this._format = handleOrFormatOrCondition; + this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (handleOrFormatOrCondition instanceof Handle) { + this._handle = handleOrFormatOrCondition; + this._client = clientOrValueProvidersOrMatchValue as AspireClient; } else { - this._handle = handleOrFormat; - this._client = clientOrValueProviders as AspireClient; + this._condition = handleOrFormatOrCondition; + this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + this._whenTrue = whenTrueOrWhenFalse; + this._whenFalse = whenFalse; } } + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return this._condition !== undefined; + } + /** * Creates a reference expression from a tagged template literal. * @@ -82,16 +106,46 @@ export class ReferenceExpression { return new ReferenceExpression(format, valueProviders); } + /** + * Creates a conditional reference expression from its constituent parts. + * + * @param condition - A value provider whose result is compared to matchValue + * @param whenTrue - The expression to use when the condition matches + * @param whenFalse - The expression to use when the condition does not match + * @param matchValue - The value to compare the condition against (defaults to "True") + * @returns A ReferenceExpression instance in conditional mode + */ + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression { + return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + } + /** * Serializes the reference expression for JSON-RPC transport. - * In template-literal mode, uses the $expr format. + * 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[] } } | MarshalledHandle { + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { if (this._handle) { return this._handle.toJSON(); } + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(this._condition), + whenTrue: this._whenTrue!.toJSON(), + whenFalse: this._whenFalse!.toJSON(), + matchValue: this._matchValue! + } + }; + } + return { $expr: { format: this._format!, @@ -100,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -107,10 +185,17 @@ export class ReferenceExpression { if (this._handle) { return `ReferenceExpression(handle)`; } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } return `ReferenceExpression(${this._format})`; } } +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. @@ -136,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -307,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -466,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/transport.ts index 7bddd74beff..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -213,6 +354,76 @@ export class CapabilityError extends Error { } } +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + } +} + +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 // ============================================================================ @@ -324,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -346,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -361,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -381,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -411,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -422,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -432,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + 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; - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + let settled = false; - this.socket = net.createConnection(pipePath); + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -475,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -533,39 +935,66 @@ export class AspireClient { throw new Error('Not connected to AppHost'); } - // 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++; + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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++; - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + 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 { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/apphost.ts index bec04446e6b..a431a7f4dfd 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/apphost.ts @@ -14,6 +14,9 @@ await hub.withProperties(async (configuredHub) => { const _partitionCount: number | undefined = await configuredHub.partitionCount.get(); }); +const _hubParent = await hub.parent.get(); +const _hubConnectionString = await hub.connectionStringExpression.get(); + const consumerGroup = await hub.addConsumerGroup('processors', { groupName: 'processor-group' }); await consumerGroup.withEventHubsRoleAssignments(eventHubs, [AzureEventHubsRole.AzureEventHubsDataReceiver]); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..6549d484798 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.EventHubs/ValidationAppHost/aspire.config.json @@ -0,0 +1,9 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "packages": { + "Aspire.Hosting.Azure.EventHubs": "" + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.aspire/settings.json deleted file mode 100644 index ad81ece42d4..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.aspire/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", - "packages": { - "Aspire.Hosting.Azure.Kusto": "" - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/.codegen-hash index 8f8a84b7520..87107730b5a 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -907FA4340642B81E5B349BF1A2F8DEE2169DBEDFCFA94EB8CE0E42473312D733 \ No newline at end of file +1AA78ABAB70ED987E5762FCD5C6DDBB4D31237014293A411FD9561CDF5A95F90 \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/aspire.ts index 7261e27146b..1a96f0e52c9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/aspire.ts @@ -9,6 +9,7 @@ import { Handle, MarshalledHandle, AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -60,9 +61,21 @@ type BicepOutputReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Az /** Handle to IAzureKeyVaultSecretReference */ type IAzureKeyVaultSecretReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultSecretReference'>; +/** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -72,6 +85,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -96,6 +112,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -126,15 +145,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -159,18 +190,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -183,12 +229,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -312,6 +364,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -342,6 +400,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -368,6 +447,10 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } +export interface AddContainerRegistryFromStringOptions { + repository?: string; +} + export interface AddContainerRegistryOptions { repository?: ParameterResource; } @@ -385,6 +468,16 @@ export interface AddParameterOptions { secret?: boolean; } +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; + secret?: boolean; +} + export interface AddReadWriteDatabaseOptions { databaseName?: string; } @@ -397,26 +490,88 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; } export interface PublishAsDockerFileOptions { configure?: (obj: ContainerResource) => Promise; } +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; +} + export interface RunAsEmulatorOptions { configureContainer?: (obj: AzureKustoEmulatorResource) => Promise; } +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + export interface RunOptions { - cancellationToken?: AbortSignal; + 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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithBindMountOptions { isReadOnly?: boolean; } @@ -425,6 +580,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDescriptionOptions { enableMarkdown?: boolean; } @@ -514,6 +675,7 @@ export interface WithPipelineStepFactoryOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -533,6 +695,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -574,6 +773,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -648,11 +921,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -667,6 +941,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -684,9 +1017,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -760,6 +1093,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -782,6 +1126,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -795,6 +1203,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -925,7 +1344,7 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs @@ -1043,11 +1462,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1077,6 +1519,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1095,16 +1548,17 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; @@ -1112,44 +1566,136 @@ export class ExecuteCommandContext { } // ============================================================================ -// PipelineConfigurationContext +// InitializeResourceEvent // ============================================================================ /** - * Type class for PipelineConfigurationContext. + * Type class for InitializeResourceEvent. */ -export class PipelineConfigurationContext { - constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Steps property */ - steps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, - set: async (value: PipelineStep[]): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', - { context: this._handle, value } - ); - } }; - /** Gets pipeline steps with the specified tag */ - async getStepsByTag(tag: string): Promise { - const rpcArgs: Record = { context: this._handle, tag }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/getStepsByTag', - rpcArgs - ); - } + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; -} + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + { context: this._handle } + ); + }, + set: async (value: PipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } + ); + } + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets pipeline steps with the specified tag */ + async getStepsByTag(tag: string): Promise { + const rpcArgs: Record = { context: this._handle, tag }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/getStepsByTag', + rpcArgs + ); + } + +} /** * Thenable wrapper for PipelineConfigurationContext that enables fluent chaining. @@ -1171,6 +1717,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1258,6 +1891,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1328,6 +1972,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1339,16 +2016,157 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); }, }; + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + } // ============================================================================ @@ -1533,86 +2351,381 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new ServiceProvider(handle, this._client); }, }; } // ============================================================================ -// DistributedApplicationBuilder +// ResourceLoggerService // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for ResourceLoggerService. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, - }; + /** Completes the log stream for a resource */ + /** @internal */ + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + } + + /** Completes the log stream by resource name */ + /** @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 ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); + } + + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ + /** @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 ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + } + + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** Waits for all dependencies of a resource to be ready */ + /** @internal */ + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + } + + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ + /** @internal */ + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); }, }; @@ -1620,548 +2733,1759 @@ export class DistributedApplicationBuilder { executionContext = { get: async (): Promise => { const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', { context: this._handle } ); return new DistributedApplicationExecutionContext(handle, this._client); }, }; - /** Builds the distributed application */ - /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', + rpcArgs + ); + } + + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); + } + + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', + rpcArgs + ); + } + + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); + } + + /** Checks whether a configuration section exists */ + 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. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + 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 ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @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 ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @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 DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @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 ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @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 ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds an Azure Data Explorer (Kusto) cluster resource */ + /** @internal */ + async _addAzureKustoClusterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Kusto/addAzureKustoCluster', + rpcArgs + ); + return new AzureKustoClusterResource(result, this._client); + } + + addAzureKustoCluster(name: string): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._addAzureKustoClusterInternal(name)); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds an Azure Data Explorer (Kusto) cluster resource */ + addAzureKustoCluster(name: string): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.addAzureKustoCluster(name))); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', rpcArgs ); - return new DistributedApplication(result, this._client); - } - - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); } - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); } - /** Adds a container registry resource */ - /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistry', + /** Checks if the environment matches the specified name */ + async isEnvironment(environmentName: string): Promise { + const rpcArgs: Record = { environment: this._handle, environmentName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isEnvironment', rpcArgs ); - return new ContainerRegistryResource(result, this._client); } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); +} + +/** + * Thenable wrapper for HostEnvironment that enables fluent chaining. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds a container resource */ - /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', - rpcArgs - ); - return new ContainerResource(result, this._client); + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); } - /** Adds a container resource built from a Dockerfile */ - /** @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 ContainerResource(result, this._client); + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); } - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); } - /** Adds a .NET tool resource */ +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ /** @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', + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', rpcArgs ); - return new DotnetToolResource(result, this._client); + return this; } - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._logInformationInternal(message)); } - /** Adds an executable resource */ + /** Logs a warning message */ /** @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', + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', rpcArgs ); - return new ExecutableResource(result, this._client); + return this; } - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._logWarningInternal(message)); } - /** Adds an external service resource */ + /** Logs an error message */ /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + logError(message: string): LoggerPromise { + return new LoggerPromise(this._logErrorInternal(message)); } - /** Adds a parameter resource */ + /** Logs a debug message */ /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', rpcArgs ); - return new ParameterResource(result, this._client); + return this; } - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._logDebugInternal(message)); } - /** Adds a parameter sourced from configuration */ + /** Logs a message with specified level */ /** @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', + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', rpcArgs ); - return new ParameterResource(result, this._client); + return this; } - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._logInternal(level, message)); } - /** Adds a connection string resource */ +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); + } + + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); + } + + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); + } + + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); + } + + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); + } + +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', rpcArgs ); - return new ResourceWithConnectionString(result, this._client); + return new Logger(result, this._client); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); } - /** Adds a .NET project resource */ +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); + } + +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', + 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 ProjectResource(result, this._client); + return new ReportingTask(result, this._client); } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); } - /** Adds a project resource with configuration options */ + /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', + 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 ProjectResource(result, this._client); + return new ReportingTask(result, this._client); } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); } - /** Adds a C# application resource */ + /** Logs a plain-text message for the reporting step */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', rpcArgs ); - return new ProjectResource(result, this._client); + return this; } - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); } - /** Adds a C# application resource with configuration options */ + /** Logs a Markdown-formatted message for the reporting step */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', rpcArgs ); - return new CSharpAppResource(result, this._client); + return this; } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); } - /** Adds an Azure Data Explorer (Kusto) cluster resource */ + /** Completes the reporting step with plain-text completion text */ /** @internal */ - async _addAzureKustoClusterInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Kusto/addAzureKustoCluster', + 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 new AzureKustoClusterResource(result, this._client); + return this; } - addAzureKustoCluster(name: string): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._addAzureKustoClusterInternal(name)); + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); } - /** Adds an Azure Bicep template resource from a file */ + /** Completes the reporting step with Markdown-formatted completion text */ /** @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', + 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 new AzureBicepResource(result, this._client); + return this; } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - /** @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 AzureBicepResource(result, this._client); +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); } - /** Adds an Azure provisioning resource to the application model */ + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); + } + + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); + } + + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); + } + + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ /** @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 AzureResourceInfrastructure(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', + 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 new AzureProvisioningResource(result, this._client); + return this; } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); } - /** Adds Azure provisioning services to the distributed application builder */ + /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _addAzureProvisioningInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', + 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 new DistributedApplicationBuilder(result, this._client); + return this; } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } - /** Adds the shared Azure environment resource to the application model */ + /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + 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 new AzureEnvironmentResource(result, this._client); + return this; } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } - /** Adds an Azure user-assigned identity resource */ + /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _addAzureUserAssignedIdentityInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + 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 new AzureUserAssignedIdentityResource(result, this._client); + return this; } - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); } - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); +} + +// ============================================================================ +// ServiceProvider +// ============================================================================ + +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); } - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); } - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); } - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); } - /** Adds an Azure Data Explorer (Kusto) cluster resource */ - addAzureKustoCluster(name: string): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.addAzureKustoCluster(name))); + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); } - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); +} + +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); } - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); + } + + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); } } // ============================================================================ -// DistributedApplicationEventing +// UserSecretsManager // ============================================================================ /** - * Type class for DistributedApplicationEventing. + * Type class for UserSecretsManager. */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Invokes the Unsubscribe method */ + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); + } + + /** Saves state to user secrets from a JSON string */ + /** @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 UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; await this._client.invokeCapability( - 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', + 'Aspire.Hosting/getOrSetSecret', rpcArgs ); return this; } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } /** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } @@ -2386,11 +4710,26 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2405,7 +4744,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2525,6 +4864,215 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -2574,23 +5122,9 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -2599,28 +5133,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -2629,23 +5150,26 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureBicepResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -2725,6 +5249,11 @@ export class AzureBicepResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -2765,6 +5294,71 @@ export class AzureBicepResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -2785,29 +5379,19 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -3032,11 +5616,26 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3051,7 +5650,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3171,6 +5770,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withLocationInternal(location: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, location }; @@ -3278,6 +5957,11 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3318,6 +6002,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets the Azure location for the shared Azure environment resource */ withLocation(location: ParameterResource): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withLocation(location))); @@ -3349,6 +6053,28 @@ export class AzureKustoClusterResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureKustoClusterResource.nameOutputReference', + { context: this._handle } + ); + return new BicepOutputReference(handle, this._client); + }, + }; + + /** Gets the ClusterUri property */ + clusterUri = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureKustoClusterResource.clusterUri', + { context: this._handle } + ); + return new BicepOutputReference(handle, this._client); + }, + }; + /** Gets the UriExpression property */ uriExpression = { get: async (): Promise => { @@ -3492,7 +6218,7 @@ export class AzureKustoClusterResource extends ResourceBuilderBase { + 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', @@ -3501,8 +6227,8 @@ export class AzureKustoClusterResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -3842,11 +6577,26 @@ export class AzureKustoClusterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKustoClusterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureKustoClusterResource(result, this._client); @@ -3861,7 +6611,7 @@ export class AzureKustoClusterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureKustoClusterResource(result, this._client); @@ -4010,6 +6760,126 @@ export class AzureKustoClusterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureKustoClusterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureKustoClusterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureKustoClusterResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureKustoClusterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureKustoClusterResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureKustoClusterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _addReadWriteDatabaseInternal(name: string, databaseName?: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -4247,23 +7117,9 @@ export class AzureKustoClusterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureKustoClusterResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -4272,28 +7128,15 @@ export class AzureKustoClusterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureKustoClusterResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -4302,23 +7145,26 @@ export class AzureKustoClusterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureKustoClusterResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureKustoClusterResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureKustoClusterResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -4358,8 +7204,8 @@ export class AzureKustoClusterResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureKustoClusterResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKustoClusterResourcePromise { return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -4368,6 +7214,11 @@ export class AzureKustoClusterResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): AzureKustoClusterResourcePromise { return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -4453,6 +7304,11 @@ export class AzureKustoClusterResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureKustoClusterResourcePromise { return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4498,6 +7354,36 @@ export class AzureKustoClusterResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Adds a Kusto read-write database resource */ addReadWriteDatabase(name: string, options?: AddReadWriteDatabaseOptions): AzureKustoReadWriteDatabaseResourcePromise { return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.addReadWriteDatabase(name, options))); @@ -4578,29 +7464,19 @@ export class AzureKustoClusterResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKustoClusterResourcePromise { - return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureKustoClusterResourcePromise { + return new AzureKustoClusterResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -4818,7 +7694,7 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -4827,8 +7703,8 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); @@ -4847,6 +7723,27 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { + 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 AzureKustoEmulatorResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureKustoEmulatorResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new AzureKustoEmulatorResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -4956,79 +7853,29 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { - 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 AzureKustoEmulatorResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKustoEmulatorResourcePromise { - const helpLink = options?.helpLink; - return new AzureKustoEmulatorResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureKustoEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new AzureKustoEmulatorResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + publishAsConnectionString(): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureKustoEmulatorResourcePromise { + const helpLink = options?.helpLink; + return new AzureKustoEmulatorResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -5036,15 +7883,15 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -5062,6 +7909,21 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new AzureKustoEmulatorResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -5148,52 +8010,39 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureKustoEmulatorResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzureKustoEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new AzureKustoEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureKustoEmulatorResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzureKustoEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -5493,7 +8342,7 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); @@ -5523,7 +8372,7 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); @@ -5569,7 +8418,7 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); @@ -5674,7 +8523,7 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); @@ -5701,11 +8550,26 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKustoEmulatorResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); @@ -5720,7 +8584,7 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureKustoEmulatorResource(result, this._client); @@ -5918,6 +8782,106 @@ export class AzureKustoEmulatorResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureKustoEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureKustoEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureKustoEmulatorResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureKustoEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureKustoEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withHostPortInternal(port: number): Promise { const rpcArgs: Record = { builder: this._handle, port }; @@ -6060,8 +9024,8 @@ export class AzureKustoEmulatorResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureKustoEmulatorResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -6070,6 +9034,11 @@ export class AzureKustoEmulatorResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -6110,31 +9079,21 @@ export class AzureKustoEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureKustoEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -6160,21 +9119,16 @@ export class AzureKustoEmulatorResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureKustoEmulatorResourcePromise { - return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -6320,6 +9274,11 @@ export class AzureKustoEmulatorResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6380,6 +9339,31 @@ export class AzureKustoEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKustoEmulatorResourcePromise { + return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets the host port for the Kusto emulator endpoint */ withHostPort(port: number): AzureKustoEmulatorResourcePromise { return new AzureKustoEmulatorResourcePromise(this._promise.then(obj => obj.withHostPort(port))); @@ -6504,7 +9488,7 @@ export class AzureKustoReadWriteDatabaseResource extends ResourceBuilderBase { + 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', @@ -6513,8 +9497,8 @@ export class AzureKustoReadWriteDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -6693,11 +9686,26 @@ export class AzureKustoReadWriteDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKustoReadWriteDatabaseResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureKustoReadWriteDatabaseResource(result, this._client); @@ -6712,7 +9720,7 @@ export class AzureKustoReadWriteDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureKustoReadWriteDatabaseResource(result, this._client); @@ -6768,68 +9776,168 @@ export class AzureKustoReadWriteDatabaseResource extends ResourceBuilderBase( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/withPipelineStepFactory', + rpcArgs + ); + return new AzureKustoReadWriteDatabaseResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKustoReadWriteDatabaseResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureKustoReadWriteDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureKustoReadWriteDatabaseResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureKustoReadWriteDatabaseResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureKustoReadWriteDatabaseResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureKustoReadWriteDatabaseResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKustoReadWriteDatabaseResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureKustoReadWriteDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onConnectionStringAvailable', rpcArgs ); return new AzureKustoReadWriteDatabaseResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureKustoReadWriteDatabaseResourcePromise { - return new AzureKustoReadWriteDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureKustoReadWriteDatabaseResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureKustoReadWriteDatabaseResourcePromise { - return new AzureKustoReadWriteDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureKustoReadWriteDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -6888,8 +9996,8 @@ export class AzureKustoReadWriteDatabaseResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureKustoReadWriteDatabaseResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKustoReadWriteDatabaseResourcePromise { return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -6898,6 +10006,11 @@ export class AzureKustoReadWriteDatabaseResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureKustoReadWriteDatabaseResourcePromise { return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -6943,6 +10056,11 @@ export class AzureKustoReadWriteDatabaseResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureKustoReadWriteDatabaseResourcePromise { return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6983,6 +10101,31 @@ export class AzureKustoReadWriteDatabaseResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKustoReadWriteDatabaseResourcePromise { + return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Defines the KQL script used to create the database */ withCreationScript(script: string): AzureKustoReadWriteDatabaseResourcePromise { return new AzureKustoReadWriteDatabaseResourcePromise(this._promise.then(obj => obj.withCreationScript(script))); @@ -7215,11 +10358,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -7234,7 +10392,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -7354,6 +10512,86 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); + } + /** Gets an output reference from an Azure Bicep template resource */ async getOutput(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -7483,6 +10721,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -7532,23 +10790,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -7557,28 +10801,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -7587,23 +10818,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureProvisioningResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -7683,6 +10917,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -7723,6 +10962,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Gets an output reference from an Azure Bicep template resource */ getOutput(name: string): Promise { return this._promise.then(obj => obj.getOutput(name)); @@ -7768,6 +11027,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -7788,29 +11052,19 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -8035,11 +11289,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -8054,7 +11323,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -8128,50 +11397,130 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); } /** Gets an output reference from an Azure Bicep template resource */ @@ -8372,23 +11721,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -8397,28 +11732,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -8427,23 +11749,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -8523,6 +11848,11 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -8563,6 +11893,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Gets an output reference from an Azure Bicep template resource */ getOutput(name: string): Promise { return this._promise.then(obj => obj.getOutput(name)); @@ -8633,29 +11983,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -8721,7 +12061,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -8730,8 +12070,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -8862,7 +12211,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8892,7 +12241,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8938,7 +12287,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8987,11 +12336,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -9006,7 +12370,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -9126,6 +12490,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -9158,8 +12622,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -9168,6 +12632,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -9238,6 +12707,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9278,6 +12752,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -9500,11 +12999,26 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -9519,7 +13033,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -9551,92 +13065,172 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 ContainerRegistryResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + 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 ContainerRegistryResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ContainerRegistryResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onResourceStopped', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 ContainerRegistryResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); } } @@ -9716,70 +13310,349 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export class ContainerResource extends ResourceBuilderBase { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageTagInternal(tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromise(this._withImageInternal(image, tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageSHA256Internal(sha256)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._withLifetimeInternal(lifetime)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsContainerInternal()); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** @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 ContainerResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @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 ContainerResource(result, this._client); } -} - -// ============================================================================ -// ContainerResource -// ============================================================================ - -export class ContainerResource extends ResourceBuilderBase { - constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + 'Aspire.Hosting/withEndpointProxySupport', rpcArgs ); return new ContainerResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } /** @internal */ @@ -9801,6 +13674,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -9851,58 +13739,43 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -9913,43 +13786,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -10038,52 +13906,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -10383,7 +14238,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -10413,7 +14268,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -10459,7 +14314,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -10564,7 +14419,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -10591,11 +14446,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -10610,7 +14480,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -10780,6 +14650,25 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -10789,6 +14678,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -10856,11 +14845,96 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -10876,36 +14950,31 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -10931,21 +15000,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -11091,6 +15155,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -11141,11 +15210,41 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -11325,41 +15424,11 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -11370,43 +15439,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -11495,52 +15559,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -11825,7 +15876,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11855,7 +15906,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11885,7 +15936,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11931,7 +15982,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -12036,7 +16087,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -12063,11 +16114,26 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -12082,7 +16148,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -12261,6 +16327,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -12368,31 +16534,21 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -12418,21 +16574,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -12583,6 +16734,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -12638,6 +16794,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -12920,41 +17101,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -12965,43 +17116,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -13090,52 +17236,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -13435,7 +17568,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13465,7 +17598,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13511,7 +17644,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13616,7 +17749,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13643,11 +17776,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13662,7 +17810,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13841,6 +17989,106 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -13983,31 +18231,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -14033,21 +18271,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -14193,6 +18426,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14248,6 +18486,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -14309,123 +18572,138 @@ export class ExecutableResource extends ResourceBuilderBase { + private async _publishAsDockerFileInternal(): 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', + 'Aspire.Hosting/publishAsDockerFile', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new ExecutableResourcePromise(this._withMcpServerInternal(path, endpointName)); + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); } /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', + 'Aspire.Hosting/publishAsDockerFileWithConfigure', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures OTLP telemetry export */ - withOtlpExporter(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withOtlpExporterInternal()); + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); } /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; + private async _withExecutableCommandInternal(command: string): Promise { + const rpcArgs: Record = { builder: this._handle, command }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', + 'Aspire.Hosting/withExecutableCommand', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withWorkingDirectoryInternal(workingDirectory: string): Promise { + const rpcArgs: Record = { builder: this._handle, workingDirectory }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withWorkingDirectory', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { - const helpLink = options?.helpLink; - return new ExecutableResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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 ExecutableResource(result, this._client); + } + + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new ExecutableResourcePromise(this._withMcpServerInternal(path, endpointName)); + } + + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/withOtlpExporter', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); + /** Configures OTLP telemetry export */ + withOtlpExporter(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withOtlpExporterInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', + 'Aspire.Hosting/withOtlpExporterProtocol', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ExecutableResourcePromise { + const helpLink = options?.helpLink; + return new ExecutableResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -14433,15 +18711,15 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -14459,6 +18737,21 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -14545,52 +18838,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -14890,7 +19170,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14920,7 +19200,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14966,7 +19246,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -15071,7 +19351,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -15098,11 +19378,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -15117,7 +19412,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -15296,6 +19591,106 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -15368,6 +19763,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -15388,31 +19803,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -15438,21 +19843,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -15598,6 +19998,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15653,6 +20058,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -15909,11 +20339,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -15928,7 +20373,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -16048,6 +20493,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -16130,6 +20655,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16165,9 +20695,29 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withPipelineConfiguration(callback))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } } @@ -16409,11 +20959,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -16428,7 +20993,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -16548,6 +21113,86 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -16630,6 +21275,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16670,6 +21320,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -16765,74 +21435,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -16840,15 +21512,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -16866,6 +21538,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -16952,52 +21639,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -17282,7 +21956,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -17312,7 +21986,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -17342,7 +22016,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -17388,7 +22062,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -17493,7 +22167,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -17520,11 +22194,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -17539,7 +22228,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -17718,6 +22407,106 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -17805,36 +22594,41 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); + } + + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -17860,21 +22654,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -18025,6 +22814,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18080,6 +22874,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -18155,23 +22974,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -18180,28 +22985,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -18210,23 +23002,26 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -18266,29 +23061,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -18394,7 +23179,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -18649,11 +23434,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -18668,7 +23468,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -18788,6 +23588,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -18865,6 +23745,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18905,6 +23790,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -19015,7 +23920,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -19024,8 +23929,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -19061,8 +23995,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -19071,6 +24005,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -19359,6 +24303,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -19426,6 +24390,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -19468,41 +24437,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -19513,43 +24452,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -19583,52 +24517,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -19711,7 +24632,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -19795,31 +24716,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -19830,21 +24741,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -19892,34 +24798,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -19933,7 +24811,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -19963,7 +24841,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -19994,7 +24872,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -20113,7 +24991,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource', (handle, client) => new AzureEnvironmentResource(handle as AzureEnvironmentResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Kusto/Aspire.Hosting.Azure.AzureKustoClusterResource', (handle, client) => new AzureKustoClusterResource(handle as AzureKustoClusterResourceHandle, client)); @@ -20204,6 +25105,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/base.ts index 9a3427e7e72..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -138,7 +138,7 @@ export class ReferenceExpression { if (this.isConditional) { return { $expr: { - condition: this._condition instanceof Handle ? this._condition.toJSON() : this._condition, + condition: extractHandleForExpr(this._condition), whenTrue: this._whenTrue!.toJSON(), whenFalse: this._whenFalse!.toJSON(), matchValue: this._matchValue! @@ -154,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -168,6 +192,10 @@ export class ReferenceExpression { } } +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. @@ -193,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -364,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -523,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/transport.ts index 7ee1ba87e3f..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -240,9 +381,7 @@ function validateCapabilityArgs( return; } - const seen = new Set(); - - const validateValue = (value: unknown, path: string): void => { + const validateValue = (value: unknown, path: string, ancestors: Set): void => { if (value === null || value === undefined) { return; } @@ -259,26 +398,29 @@ function validateCapabilityArgs( return; } - if (seen.has(value)) { - return; + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); } - seen.add(value); - - if (Array.isArray(value)) { - for (let i = 0; i < value.length; i++) { - validateValue(value[i], `${path}[${i}]`); + ancestors.add(value); + try { + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + validateValue(value[i], `${path}[${i}]`, ancestors); + } + return; } - return; - } - for (const [key, nestedValue] of Object.entries(value)) { - validateValue(nestedValue, `${path}.${key}`); + 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); + validateValue(value, key, new Set()); } } @@ -393,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -415,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -430,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -450,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -480,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -491,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -501,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + if (this.connected) { + return Promise.resolve(); + } - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + 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.socket = net.createConnection(pipePath); + this._connectPromise = new Promise((resolve, reject) => { + const socket = net.createConnection(pipePath); + this.socket = socket; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -544,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -603,40 +936,65 @@ export class AspireClient { } validateCapabilityArgs(capabilityId, args); - - // 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++; + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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; + // Wrap handles automatically + return wrapIfHandle(result, this) as T; + } finally { + this._pendingCalls--; + if (this._pendingCalls === 0) { + this.socket?.unref(); + } + } } finally { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/apphost.ts index 73b15edcf04..018fed7bff3 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/apphost.ts @@ -17,6 +17,8 @@ await customDatabase.withCreationScript(".create database AnalyticsDb ifnotexist const _isEmulator: boolean = await kusto.isEmulator.get(); const _clusterUri = await kusto.uriExpression.get(); const _clusterConnectionString = await kusto.connectionStringExpression.get(); +const _clusterNameOutput = await kusto.nameOutputReference.get(); +const _clusterUriOutput = await kusto.clusterUri.get(); const _defaultDatabaseName: string = await defaultDatabase.databaseName.get(); const _defaultDatabaseParent = await defaultDatabase.parent.get(); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..e91e722a89c --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Kusto/ValidationAppHost/aspire.config.json @@ -0,0 +1,9 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "packages": { + "Aspire.Hosting.Azure.Kusto": "" + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.aspire/settings.json deleted file mode 100644 index d292b9e3fd3..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.aspire/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", - "packages": { - "Aspire.Hosting.Azure.Redis": "", - "Aspire.Hosting.Azure.KeyVault": "" - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/.codegen-hash index ab983cca1c6..8ddb4ba3e89 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -8219D8FB45071475E25C34BD089491A4D1EDACC6E63445C8D275D511F7DC35B6 \ No newline at end of file +FA10F1DA8B26F3364B872925C810985E3778693EE2AD79AD67A9BFFFC82A1555 \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/aspire.ts index e310905e705..9486b01787a 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/aspire.ts @@ -8,6 +8,8 @@ import { AspireClient as AspireClientRpc, Handle, MarshalledHandle, + AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -71,9 +73,21 @@ type RedisCommanderResourceHandle = Handle<'Aspire.Hosting.Redis/Aspire.Hosting. /** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -83,6 +97,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -107,6 +124,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -137,15 +157,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -170,18 +202,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -194,12 +241,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -264,6 +317,7 @@ export enum EndpointProperty { Scheme = "Scheme", TargetPort = "TargetPort", HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", } /** Enum type for IconVariant */ @@ -339,6 +393,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -369,6 +429,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -395,7 +476,7 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } -export interface AddContainerRegistry1Options { +export interface AddContainerRegistryFromStringOptions { repository?: string; } @@ -408,16 +489,21 @@ export interface AddDockerfileOptions { stage?: string; } -export interface AddParameter1Options { - publishValueAsDefault?: boolean; +export interface AddParameterFromConfigurationOptions { secret?: boolean; } -export interface AddParameterFromConfigurationOptions { +export interface AddParameterOptions { secret?: boolean; } -export interface AddParameterOptions { +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; secret?: boolean; } @@ -438,22 +524,88 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; } export interface RunAsContainerOptions { configureContainer?: (obj: RedisResource) => Promise; } +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + export interface RunOptions { - cancellationToken?: AbortSignal; + 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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithBindMountOptions { isReadOnly?: boolean; } @@ -462,6 +614,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDataBindMountOptions { isReadOnly?: boolean; } @@ -579,6 +737,7 @@ export interface WithRedisInsightOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -598,6 +757,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -639,6 +835,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -713,11 +983,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -732,6 +1003,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -749,9 +1079,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -825,6 +1155,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -847,6 +1188,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -860,6 +1265,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -926,6 +1342,16 @@ export class EndpointReference { }, }; + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { @@ -980,13 +1406,22 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs ); } + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + 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 + ); + } + } /** @@ -1007,6 +1442,11 @@ export class EndpointReferencePromise implements PromiseLike return this._promise.then(obj => obj.getValueAsync(options)); } + /** 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 { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + } // ============================================================================ @@ -1084,11 +1524,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1118,6 +1581,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1136,16 +1610,17 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; @@ -1153,34 +1628,126 @@ export class ExecuteCommandContext { } // ============================================================================ -// PipelineConfigurationContext +// InitializeResourceEvent // ============================================================================ /** - * Type class for PipelineConfigurationContext. + * Type class for InitializeResourceEvent. */ -export class PipelineConfigurationContext { - constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Steps property */ - steps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, - set: async (value: PipelineStep[]): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', - { context: this._handle, value } - ); + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + { context: this._handle } + ); + }, + set: async (value: PipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } + ); } }; + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; @@ -1212,6 +1779,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1299,6 +1953,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1369,6 +2034,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1380,18 +2078,159 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; } +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + +} + // ============================================================================ // ProjectResourceOptions // ============================================================================ @@ -1574,807 +2413,2207 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new ServiceProvider(handle, this._client); }, }; } // ============================================================================ -// DistributedApplicationBuilder +// ResourceLoggerService // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for ResourceLoggerService. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, - }; - - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', - { context: this._handle } - ); - return new DistributedApplicationEventing(handle, this._client); - }, - }; - - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', - { context: this._handle } - ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, - }; - - /** Builds the distributed application */ + /** Completes the log stream for a resource */ /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', rpcArgs ); - return new DistributedApplication(result, this._client); + return this; } - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); } - /** Adds a connection string with a reference expression */ + /** Completes the log stream by resource name */ /** @internal */ - async _addConnectionString1Internal(name: string, connectionStringExpression: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringExpression', + async _completeLogByNameInternal(resourceName: string): Promise { + const rpcArgs: Record = { loggerService: this._handle, resourceName }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLogByName', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return this; } - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionString1Internal(name, connectionStringExpression)); + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); } - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); } - /** Adds a container registry resource */ + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistry', + 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 new ContainerRegistryResource(result, this._client); + return this; } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + const targetState = options?.targetState; + return new ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); } - /** Adds a container registry with string endpoint */ - /** @internal */ - async _addContainerRegistry1Internal(name: string, endpoint: string, repository?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistryFromString', + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', rpcArgs ); - return new ContainerRegistryResource(result, this._client); } - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistry1Internal(name, endpoint, repository)); + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); } - /** Adds a container resource */ + /** Waits for all dependencies of a resource to be ready */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); } - /** Adds a container resource built from a Dockerfile */ + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ /** @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', + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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 new ContainerResource(result, this._client); + return this; } - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; } - /** Adds a .NET tool resource */ + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', + rpcArgs + ); + } + + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); + } + + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', + rpcArgs + ); + } + + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); + } + + /** Checks whether a configuration section exists */ + 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. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + 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 ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @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 ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @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 DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @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 ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @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 ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds an Azure Key Vault resource */ + /** @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 AzureKeyVaultResource(result, this._client); + } + + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._addAzureKeyVaultInternal(name)); + } + + /** Adds an Azure Managed Redis resource */ + /** @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 AzureManagedRedisResource(result, this._client); + } + + addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._addAzureManagedRedisInternal(name)); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + + /** Adds a Redis container resource with specific port */ + /** @internal */ + async _addRedisWithPortInternal(name: string, port?: number): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Redis/addRedisWithPort', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { + const port = options?.port; + return new RedisResourcePromise(this._addRedisWithPortInternal(name, port)); + } + + /** Adds a Redis container resource */ + /** @internal */ + async _addRedisInternal(name: string, port?: number, password?: ParameterResource): Promise { + 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 RedisResource(result, this._client); + } + + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { + const port = options?.port; + const password = options?.password; + return new RedisResourcePromise(this._addRedisInternal(name, port, password)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds an Azure Key Vault resource */ + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.addAzureKeyVault(name))); + } + + /** Adds an Azure Managed Redis resource */ + addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.addAzureManagedRedis(name))); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + + /** Adds a Redis container resource with specific port */ + addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.addRedisWithPort(name, options))); + } + + /** Adds a Redis container resource */ + addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.addRedis(name, options))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', + rpcArgs + ); + } + + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', + rpcArgs + ); + } + + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); + } + + /** Checks if the environment matches the specified name */ + 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. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); + } + + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); + } + + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); + } + + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); + } + +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ /** @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', + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', rpcArgs ); - return new DotnetToolResource(result, this._client); + return this; } - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._logInformationInternal(message)); } - /** Adds an executable resource */ + /** Logs a warning message */ /** @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', + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', rpcArgs ); - return new ExecutableResource(result, this._client); + return this; } - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._logWarningInternal(message)); } - /** Adds an external service resource */ + /** Logs an error message */ /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + logError(message: string): LoggerPromise { + return new LoggerPromise(this._logErrorInternal(message)); } - /** Adds an external service with a URI */ + /** Logs a debug message */ /** @internal */ - async _addExternalService2Internal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceUri', + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService2Internal(name, uri)); + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._logDebugInternal(message)); } - /** Adds an external service with a parameter URL */ + /** Logs a message with specified level */ /** @internal */ - async _addExternalService1Internal(name: string, urlParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, urlParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceParameter', + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService1Internal(name, urlParameter)); + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._logInternal(level, message)); } - /** Adds a parameter resource */ - /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', - rpcArgs - ); - return new ParameterResource(result, this._client); - } +} - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); - } +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds a parameter with a default value */ - /** @internal */ - async _addParameter1Internal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameterWithValue', - rpcArgs - ); - return new ParameterResource(result, this._client); + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - const publishValueAsDefault = options?.publishValueAsDefault; - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameter1Internal(name, value, publishValueAsDefault, secret)); + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); } - /** Adds a parameter sourced from configuration */ - /** @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 ParameterResource(result, this._client); + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); } - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); } - /** Adds a connection string resource */ - /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', - rpcArgs - ); - return new ResourceWithConnectionString(result, this._client); + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); } - /** Adds a .NET project resource */ +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', rpcArgs ); - return new ProjectResource(result, this._client); + return new Logger(result, this._client); } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); } - /** Adds a project resource with configuration options */ - /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', - rpcArgs - ); - return new ProjectResource(result, this._client); +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); } - /** Adds a C# application resource */ +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + 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 ProjectResource(result, this._client); + return new ReportingTask(result, this._client); } - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); } - /** Adds a C# application resource with configuration options */ + /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', + 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 CSharpAppResource(result, this._client); + return new ReportingTask(result, this._client); } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); } - /** Adds an Azure Managed Redis resource */ + /** Logs a plain-text message for the reporting step */ /** @internal */ - async _addAzureManagedRedisInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Redis/addAzureManagedRedis', + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', rpcArgs ); - return new AzureManagedRedisResource(result, this._client); + return this; } - addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._addAzureManagedRedisInternal(name)); + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); } - /** Adds an Azure Key Vault resource */ + /** Logs a Markdown-formatted message for the reporting step */ /** @internal */ - async _addAzureKeyVaultInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.KeyVault/addAzureKeyVault', + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', rpcArgs ); - return new AzureKeyVaultResource(result, this._client); + return this; } - addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._addAzureKeyVaultInternal(name)); + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); } - /** Adds an Azure Bicep template resource from a file */ + /** Completes the reporting step with plain-text completion text */ /** @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', + 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 new AzureBicepResource(result, this._client); + return this; } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); } - /** Adds an Azure Bicep template resource from inline Bicep content */ + /** Completes the reporting step with Markdown-formatted completion text */ /** @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', + 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 new AzureBicepResource(result, this._client); + return this; } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } - /** Adds an Azure provisioning resource to the application model */ - /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); } - /** Adds Azure provisioning services to the distributed application builder */ - /** @internal */ - async _addAzureProvisioningInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', - rpcArgs - ); - return new DistributedApplicationBuilder(result, this._client); + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); } - /** Adds the shared Azure environment resource to the application model */ + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); + } + + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + 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 new AzureEnvironmentResource(result, this._client); + return this; } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); } - /** Adds an Azure user-assigned identity resource */ + /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _addAzureUserAssignedIdentityInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + 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 new AzureUserAssignedIdentityResource(result, this._client); + return this; } - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } - /** Adds a Redis container resource with specific port */ + /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _addRedisWithPortInternal(name: string, port?: number): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Redis/addRedisWithPort', + 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 new RedisResource(result, this._client); + return this; } - addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { - const port = options?.port; - return new RedisResourcePromise(this._addRedisWithPortInternal(name, port)); + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } - /** Adds a Redis container resource */ + /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _addRedisInternal(name: string, port?: number, password?: ParameterResource): Promise { - 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', + 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 new RedisResource(result, this._client); + return this; } - addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { - const port = options?.port; - const password = options?.password; - return new RedisResourcePromise(this._addRedisInternal(name, port, password)); + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); - } - - /** Adds a connection string with a reference expression */ - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionString1(name, connectionStringExpression))); + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); } - /** Adds a container registry with string endpoint */ - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry1(name, endpoint, options))); + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); - } +} - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); - } +// ============================================================================ +// ServiceProvider +// ============================================================================ - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); - } +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); - } + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); } - /** Adds an external service with a URI */ - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService2(name, uri))); + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); } - /** Adds an external service with a parameter URL */ - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService1(name, urlParameter))); + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); } - /** Adds a parameter with a default value */ - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter1(name, value, options))); + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); } - /** Adds an Azure Managed Redis resource */ - addAzureManagedRedis(name: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.addAzureManagedRedis(name))); + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); } - /** Adds an Azure Key Vault resource */ - addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.addAzureKeyVault(name))); - } +} - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); - } +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); } - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); } - /** Adds a Redis container resource with specific port */ - addRedisWithPort(name: string, options?: AddRedisWithPortOptions): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.addRedisWithPort(name, options))); + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); } - /** Adds a Redis container resource */ - addRedis(name: string, options?: AddRedisOptions): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.addRedis(name, options))); + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); } } // ============================================================================ -// DistributedApplicationEventing +// UserSecretsManager // ============================================================================ /** - * Type class for DistributedApplicationEventing. + * Type class for UserSecretsManager. */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Invokes the Unsubscribe method */ + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); + } + + /** Saves state to user secrets from a JSON string */ /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; + 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.Eventing/IDistributedApplicationEventing.unsubscribe', + 'Aspire.Hosting/saveStateJson', rpcArgs ); return this; } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + /** @internal */ + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting/getOrSetSecret', + rpcArgs + ); + return this; + } + + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } /** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } @@ -2587,23 +4826,38 @@ export class AzureBicepResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCommand', + 'Aspire.Hosting/withCommand', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureBicepResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureBicepResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2618,7 +4872,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2661,36 +4915,6 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureBicepResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -2768,6 +4992,86 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -2783,6 +5087,135 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -2832,23 +5265,9 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -2857,28 +5276,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -2887,13 +5293,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -2902,8 +5310,9 @@ export class AzureBicepResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3003,39 +5417,94 @@ export class AzureBicepResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Key Vault roles to a resource */ + withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } - /** Assigns Key Vault roles to a resource */ - withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); } /** Publishes an Azure resource to the manifest as a connection string */ @@ -3058,29 +5527,19 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -3305,11 +5764,26 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3324,7 +5798,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3367,36 +5841,6 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -3474,6 +5918,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -3596,6 +6120,11 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3616,16 +6145,6 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -3646,6 +6165,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -3743,7 +6282,7 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { + 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', @@ -3752,8 +6291,8 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -4093,11 +6641,26 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKeyVaultResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureKeyVaultResource(result, this._client); @@ -4112,7 +6675,7 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureKeyVaultResource(result, this._client); @@ -4184,36 +6747,6 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureKeyVaultResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureKeyVaultResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -4291,6 +6824,126 @@ export class AzureKeyVaultResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -4573,53 +7226,26 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureKeyVaultResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExisting', - rpcArgs - ); - return new AzureKeyVaultResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._runAsExistingInternal(name, resourceGroup)); - } - - /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', + 'Aspire.Hosting.Azure/runAsExisting', rpcArgs ); return new AzureKeyVaultResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureKeyVaultResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureKeyVaultResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -4628,13 +7254,15 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -4643,8 +7271,9 @@ export class AzureKeyVaultResource extends ResourceBuilderBase obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureKeyVaultResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -4694,6 +7323,11 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -4779,6 +7413,11 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4804,16 +7443,6 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -4834,6 +7463,36 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -4934,29 +7593,19 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -5181,11 +7830,26 @@ export class AzureKeyVaultSecretResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKeyVaultSecretResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureKeyVaultSecretResource(result, this._client); @@ -5200,7 +7864,7 @@ export class AzureKeyVaultSecretResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureKeyVaultSecretResource(result, this._client); @@ -5243,36 +7907,6 @@ export class AzureKeyVaultSecretResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureKeyVaultSecretResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureKeyVaultSecretResourcePromise { - return new AzureKeyVaultSecretResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureKeyVaultSecretResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureKeyVaultSecretResourcePromise { - return new AzureKeyVaultSecretResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -5350,6 +7984,86 @@ export class AzureKeyVaultSecretResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -5442,6 +8156,11 @@ export class AzureKeyVaultSecretResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureKeyVaultSecretResourcePromise { return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5462,16 +8181,6 @@ export class AzureKeyVaultSecretResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureKeyVaultSecretResourcePromise { - return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureKeyVaultSecretResourcePromise { - return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureKeyVaultSecretResourcePromise { return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -5492,6 +8201,26 @@ export class AzureKeyVaultSecretResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureKeyVaultSecretResourcePromise { return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -5508,6 +8237,28 @@ export class AzureManagedRedisResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.nameOutputReference', + { context: this._handle } + ); + return new BicepOutputReference(handle, this._client); + }, + }; + + /** Gets the Id property */ + id = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureManagedRedisResource.id', + { context: this._handle } + ); + return new BicepOutputReference(handle, this._client); + }, + }; + /** Gets the UseAccessKeyAuthentication property */ useAccessKeyAuthentication = { get: async (): Promise => { @@ -5672,7 +8423,7 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { + 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', @@ -5681,8 +8432,8 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -5861,11 +8621,26 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureManagedRedisResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureManagedRedisResource(result, this._client); @@ -5880,7 +8655,7 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureManagedRedisResource(result, this._client); @@ -5924,110 +8699,195 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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 PipelineStepContext(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/withRemoteImageName', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new AzureManagedRedisResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a pipeline step to the resource */ + 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 AzureManagedRedisResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new AzureManagedRedisResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureManagedRedisResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureManagedRedisResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureManagedRedisResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onConnectionStringAvailable', rpcArgs ); return new AzureManagedRedisResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 AzureManagedRedisResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureManagedRedisResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureManagedRedisResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._onResourceReadyInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', rpcArgs ); + return new AzureManagedRedisResource(result, this._client); + } + + /** Assigns Key Vault roles to a resource */ + withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._withKeyVaultRoleAssignmentsInternal(target, roles)); } /** @internal */ @@ -6082,21 +8942,6 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.KeyVault/withKeyVaultRoleAssignments', - rpcArgs - ); - return new AzureManagedRedisResource(result, this._client); - } - - /** Assigns Key Vault roles to a resource */ - withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._withKeyVaultRoleAssignmentsInternal(target, roles)); - } - /** Gets an output reference from an Azure Bicep template resource */ async getOutput(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -6295,23 +9140,9 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureManagedRedisResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -6320,28 +9151,15 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureManagedRedisResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -6350,13 +9168,15 @@ export class AzureManagedRedisResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -6365,8 +9185,9 @@ export class AzureManagedRedisResource extends ResourceBuilderBase obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureManagedRedisResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureManagedRedisResourcePromise { return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -6411,6 +9232,11 @@ export class AzureManagedRedisResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureManagedRedisResourcePromise { return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -6456,6 +9282,11 @@ export class AzureManagedRedisResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureManagedRedisResourcePromise { return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6476,16 +9307,6 @@ export class AzureManagedRedisResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureManagedRedisResourcePromise { return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -6506,6 +9327,36 @@ export class AzureManagedRedisResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Key Vault roles to a resource */ + withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); + } + /** Configures Azure Managed Redis to run in a local container */ runAsContainer(options?: RunAsContainerOptions): AzureManagedRedisResourcePromise { return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.runAsContainer(options))); @@ -6521,11 +9372,6 @@ export class AzureManagedRedisResourcePromise implements PromiseLike obj.withAccessKeyAuthenticationWithKeyVault(keyVaultBuilder))); } - /** Assigns Key Vault roles to a resource */ - withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); - } - /** Gets an output reference from an Azure Bicep template resource */ getOutput(name: string): Promise { return this._promise.then(obj => obj.getOutput(name)); @@ -6596,29 +9442,19 @@ export class AzureManagedRedisResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureManagedRedisResourcePromise { - return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureManagedRedisResourcePromise { + return new AzureManagedRedisResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -6843,11 +9679,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -6862,7 +9713,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -6905,36 +9756,6 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -7012,6 +9833,86 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -7156,6 +10057,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -7205,23 +10126,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -7230,28 +10137,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -7260,13 +10154,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -7275,8 +10171,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -7376,16 +10278,6 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -7406,6 +10298,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -7456,6 +10368,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -7476,29 +10393,19 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -7723,11 +10630,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -7742,7 +10664,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -7785,36 +10707,6 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -7892,6 +10784,86 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -8105,23 +11077,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -8130,28 +11088,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -8160,13 +11105,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -8175,8 +11122,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -8276,16 +11229,6 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -8306,6 +11249,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -8381,29 +11344,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -8469,7 +11422,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -8478,8 +11431,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -8610,7 +11572,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8640,7 +11602,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8686,7 +11648,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8735,11 +11697,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8754,7 +11731,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -8797,36 +11774,6 @@ export class ConnectionStringResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ConnectionStringResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -8904,6 +11851,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -8951,8 +11998,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -8961,6 +12008,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -9031,6 +12083,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9051,16 +12108,6 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -9081,6 +12128,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -9308,11 +12380,26 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -9327,7 +12414,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -9370,36 +12457,6 @@ export class ContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ContainerRegistryResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -9477,6 +12534,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -9529,125 +12666,394 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withUrlsCallback(callback))); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Key Vault roles to a resource */ + withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export class ContainerResource extends ResourceBuilderBase { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageTagInternal(tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromise(this._withImageInternal(image, tag)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @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 ContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageSHA256Internal(sha256)); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** @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 ContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); } - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @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 ContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._withLifetimeInternal(lifetime)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @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 ContainerResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsContainerInternal()); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** @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 ContainerResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** @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 ContainerResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); } - /** Assigns Key Vault roles to a resource */ - withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResource(result, this._client); } -} + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); + } -// ============================================================================ -// ContainerResource -// ============================================================================ + /** @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 ContainerResource(result, this._client); + } -export class ContainerResource extends ResourceBuilderBase { - constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + 'Aspire.Hosting/withEndpointProxySupport', rpcArgs ); return new ContainerResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } /** @internal */ @@ -9669,6 +13075,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -9719,58 +13140,43 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -9781,43 +13187,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -9906,52 +13307,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -10251,7 +13639,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -10281,7 +13669,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -10327,7 +13715,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -10432,7 +13820,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -10459,11 +13847,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -10478,7 +13881,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -10648,6 +14051,25 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -10657,6 +14079,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -10706,7 +14228,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ContainerResource(result, this._client); @@ -10739,11 +14261,96 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -10759,36 +14366,31 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -10814,21 +14416,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -10974,6 +14571,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -11024,11 +14626,41 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -11174,58 +14806,50 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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 CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironment', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -11236,43 +14860,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -11361,52 +14980,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -11691,7 +15297,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11721,7 +15327,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11751,7 +15357,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11797,7 +15403,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11902,7 +15508,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11929,11 +15535,26 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -11948,7 +15569,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -12127,6 +15748,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -12176,7 +15897,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -12239,36 +15960,31 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -12294,21 +16010,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -12459,6 +16170,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -12514,6 +16230,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -12801,41 +16542,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -12846,43 +16557,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -12971,52 +16677,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -13316,7 +17009,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13346,7 +17039,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13392,7 +17085,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13497,7 +17190,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13524,11 +17217,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13543,7 +17251,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13722,6 +17430,106 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -13771,7 +17579,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -13879,31 +17687,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -13929,21 +17727,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -14089,6 +17882,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14144,6 +17942,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -14209,6 +18032,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -14276,41 +18164,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -14321,43 +18179,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -14446,52 +18299,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -14791,7 +18631,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14821,7 +18661,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14867,7 +18707,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14972,7 +18812,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -14999,11 +18839,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -15018,7 +18873,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -15149,52 +19004,152 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -15246,7 +19201,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ExecutableResource(result, this._client); @@ -15284,6 +19239,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -15304,31 +19279,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -15354,21 +19319,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -15514,6 +19474,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15569,6 +19534,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -15830,11 +19820,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -15849,7 +19854,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -15892,36 +19897,6 @@ export class ExternalServiceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ExternalServiceResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -15999,6 +19974,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -16096,6 +20151,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16116,16 +20176,6 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -16146,6 +20196,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -16390,11 +20460,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -16409,7 +20494,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -16453,110 +20538,160 @@ export class ParameterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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 PipelineStepContext(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/withRemoteImageName', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new ParameterResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a pipeline step to the resource */ + 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 ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); return new ParameterResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ParameterResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onResourceStopped', rpcArgs ); return new ParameterResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ParameterResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ParameterResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -16656,6 +20791,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16676,16 +20816,6 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -16706,6 +20836,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -16806,74 +20956,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -16881,15 +21033,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -16907,6 +21059,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -16993,52 +21160,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -17323,7 +21477,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -17353,7 +21507,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -17383,7 +21537,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -17429,7 +21583,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -17534,7 +21688,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -17561,11 +21715,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -17580,7 +21749,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -17662,101 +21831,201 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ProjectResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @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 PipelineStepContext(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 ProjectResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + 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 ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ProjectResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/onResourceStopped', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -17808,7 +22077,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ProjectResource(result, this._client); @@ -17861,29 +22130,29 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -17891,6 +22160,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -17916,21 +22190,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -18081,6 +22350,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18136,6 +22410,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -18371,7 +22670,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -18380,8 +22679,8 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -18400,6 +22699,27 @@ export class RedisCommanderResource extends ResourceBuilderBase { + 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 RedisCommanderResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisCommanderResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -18531,41 +22851,11 @@ export class RedisCommanderResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -18576,43 +22866,38 @@ export class RedisCommanderResource extends ResourceBuilderBase Promise): RedisCommanderResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -18701,52 +22986,39 @@ export class RedisCommanderResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisCommanderResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new RedisCommanderResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisCommanderResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisCommanderResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -19046,7 +23318,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -19076,7 +23348,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -19122,7 +23394,7 @@ export class RedisCommanderResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -19227,7 +23499,7 @@ export class RedisCommanderResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -19254,11 +23526,26 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -19273,7 +23560,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -19432,43 +23719,143 @@ export class RedisCommanderResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** @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 RedisCommanderResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): RedisCommanderResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new RedisCommanderResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 RedisCommanderResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 RedisCommanderResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 RedisCommanderResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._onInitializeResourceInternal(callback)); } /** @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; + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withVolume', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): RedisCommanderResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new RedisCommanderResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 RedisCommanderResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -19520,7 +23907,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -19630,8 +24017,8 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisCommanderResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -19640,6 +24027,11 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -19680,31 +24072,21 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -19730,21 +24112,16 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -19890,6 +24267,11 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -19950,6 +24332,31 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -20190,7 +24597,7 @@ export class RedisInsightResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -20199,8 +24606,8 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -20219,6 +24626,27 @@ export class RedisInsightResource extends ResourceBuilderBase { + 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 RedisInsightResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisInsightResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -20350,41 +24778,11 @@ export class RedisInsightResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -20395,43 +24793,38 @@ export class RedisInsightResource extends ResourceBuilderBase Promise): RedisInsightResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -20520,52 +24913,39 @@ export class RedisInsightResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisInsightResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new RedisInsightResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisInsightResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisInsightResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -20865,7 +25245,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -20895,7 +25275,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -20941,7 +25321,7 @@ export class RedisInsightResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -21046,7 +25426,7 @@ export class RedisInsightResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -21073,11 +25453,26 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -21092,7 +25487,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -21290,6 +25685,106 @@ export class RedisInsightResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 RedisInsightResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 RedisInsightResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 RedisInsightResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 RedisInsightResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 RedisInsightResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -21339,7 +25834,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -21481,8 +25976,8 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisInsightResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -21491,6 +25986,11 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -21531,31 +26031,21 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -21581,21 +26071,16 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -21741,6 +26226,11 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -21801,6 +26291,31 @@ export class RedisInsightResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -21876,7 +26391,18 @@ export class RedisResource extends ResourceBuilderBase { 'Aspire.Hosting.ApplicationModel/RedisResource.port', { context: this._handle } ); - return new EndpointReferenceExpression(handle, this._client); + return new EndpointReferenceExpression(handle, this._client); + }, + }; + + /** Gets the PasswordParameter property */ + passwordParameter = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/RedisResource.passwordParameter', + { context: this._handle } + ); + return new ParameterResource(handle, this._client); }, }; @@ -21888,12 +26414,6 @@ export class RedisResource extends ResourceBuilderBase { { context: this._handle } ); }, - set: async (value: boolean): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/RedisResource.setTlsEnabled', - { context: this._handle, value } - ); - } }; /** Gets the ConnectionStringExpression property */ @@ -22162,7 +26682,7 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -22171,8 +26691,8 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResource(result, this._client); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisResourcePromise { return new RedisResourcePromise(this._withBuildArgInternal(name, value)); } @@ -22180,7 +26700,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisResource(result, this._client); @@ -22191,6 +26711,27 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withBuildSecretInternal(name, value)); } + /** @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 RedisResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -22322,41 +26863,11 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -22367,43 +26878,38 @@ export class RedisResource extends ResourceBuilderBase { } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { return new RedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -22437,7 +26943,7 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + 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', @@ -22446,8 +26952,8 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): RedisResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise { return new RedisResourcePromise(this._withConnectionPropertyInternal(name, value)); } @@ -22522,52 +27028,48 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new RedisResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new RedisResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise { + return new RedisResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', + 'Aspire.Hosting/withReference', rpcArgs ); return new RedisResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisResourcePromise { - return new RedisResourcePromise(this._withServiceReferenceInternal(source)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', rpcArgs ); - return new RedisResource(result, this._client); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisResourcePromise { - return new RedisResourcePromise(this._withServiceReferenceNamedInternal(source, name)); } /** @internal */ @@ -22867,7 +27369,7 @@ export class RedisResource extends ResourceBuilderBase { private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisResource(result, this._client); @@ -22897,7 +27399,7 @@ export class RedisResource extends ResourceBuilderBase { private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisResource(result, this._client); @@ -22943,7 +27445,7 @@ export class RedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisResource(result, this._client); @@ -23048,7 +27550,7 @@ export class RedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisResource(result, this._client); @@ -23075,11 +27577,26 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisResourcePromise { + return new RedisResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisResource(result, this._client); @@ -23094,7 +27611,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisResource(result, this._client); @@ -23292,6 +27809,126 @@ export class RedisResource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 RedisResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 RedisResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 RedisResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 RedisResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 RedisResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 RedisResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -23341,7 +27978,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new RedisResource(result, this._client); @@ -23569,8 +28206,8 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -23579,6 +28216,11 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -23619,31 +28261,21 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -23654,8 +28286,8 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): RedisResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -23679,19 +28311,19 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Adds a reference to a URI */ @@ -23839,6 +28471,11 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -23899,6 +28536,36 @@ export class RedisResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -24014,23 +28681,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -24039,28 +28692,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -24069,13 +28709,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -24084,8 +28726,9 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -24125,29 +28768,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -24161,11 +28794,41 @@ export class ComputeResource extends ResourceBuilderBase super(handle, 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 ComputeResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ComputeResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + /** @internal */ private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ComputeResource(result, this._client); @@ -24193,6 +28856,16 @@ export class ComputeResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + /** Associates an Azure user-assigned identity with a compute resource */ withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): ComputeResourcePromise { return new ComputeResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); @@ -24213,7 +28886,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -24468,11 +29141,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -24487,7 +29175,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -24530,36 +29218,6 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._excludeFromMcpInternal()); } - /** @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 Resource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 Resource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -24637,6 +29295,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withKeyVaultRoleAssignmentsInternal(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -24729,6 +29467,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -24749,16 +29492,6 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -24779,6 +29512,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Key Vault roles to a resource */ withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withKeyVaultRoleAssignments(target, roles))); @@ -24894,7 +29647,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -24903,8 +29656,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -24940,8 +29722,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -24950,6 +29732,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -25238,6 +30030,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -25305,6 +30117,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -25347,41 +30164,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -25392,43 +30179,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -25462,52 +30244,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -25590,7 +30359,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -25674,31 +30443,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -25709,21 +30468,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -25771,34 +30525,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -25812,7 +30538,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -25842,7 +30568,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -25873,7 +30599,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -25992,7 +30718,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { const error = reason instanceof Error ? reason : new Error(String(reason)); - if (reason instanceof CapabilityError) { + 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) { @@ -26023,8 +30751,12 @@ process.on('unhandledRejection', (reason: unknown) => { }); process.on('uncaughtException', (error: Error) => { - console.error(`\n❌ Uncaught Exception: ${error.message}`); - if (error.stack) { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + if (!(error instanceof AppHostUsageError) && error.stack) { console.error(error.stack); } process.exit(1); @@ -26035,23 +30767,46 @@ process.on('uncaughtException', (error: Error) => { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource', (handle, client) => new AzureEnvironmentResource(handle as AzureEnvironmentResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.AzureKeyVaultResource', (handle, client) => new AzureKeyVaultResource(handle as AzureKeyVaultResourceHandle, client)); @@ -26080,6 +30835,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/base.ts index 7778b0f1737..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -43,22 +43,46 @@ export class ReferenceExpression { private readonly _format?: string; private readonly _valueProviders?: unknown[]; + // Conditional mode fields + private readonly _condition?: unknown; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; + private readonly _matchValue?: string; + // Handle mode fields (when wrapping a server-returned handle) private readonly _handle?: Handle; private readonly _client?: AspireClient; constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(handleOrFormat: Handle | string, clientOrValueProviders: AspireClient | unknown[]) { - if (typeof handleOrFormat === 'string') { - this._format = handleOrFormat; - this._valueProviders = clientOrValueProviders as unknown[]; + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression + ) { + if (typeof handleOrFormatOrCondition === 'string') { + this._format = handleOrFormatOrCondition; + this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (handleOrFormatOrCondition instanceof Handle) { + this._handle = handleOrFormatOrCondition; + this._client = clientOrValueProvidersOrMatchValue as AspireClient; } else { - this._handle = handleOrFormat; - this._client = clientOrValueProviders as AspireClient; + this._condition = handleOrFormatOrCondition; + this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + this._whenTrue = whenTrueOrWhenFalse; + this._whenFalse = whenFalse; } } + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return this._condition !== undefined; + } + /** * Creates a reference expression from a tagged template literal. * @@ -82,16 +106,46 @@ export class ReferenceExpression { return new ReferenceExpression(format, valueProviders); } + /** + * Creates a conditional reference expression from its constituent parts. + * + * @param condition - A value provider whose result is compared to matchValue + * @param whenTrue - The expression to use when the condition matches + * @param whenFalse - The expression to use when the condition does not match + * @param matchValue - The value to compare the condition against (defaults to "True") + * @returns A ReferenceExpression instance in conditional mode + */ + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression { + return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + } + /** * Serializes the reference expression for JSON-RPC transport. - * In template-literal mode, uses the $expr format. + * 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[] } } | MarshalledHandle { + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { if (this._handle) { return this._handle.toJSON(); } + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(this._condition), + whenTrue: this._whenTrue!.toJSON(), + whenFalse: this._whenFalse!.toJSON(), + matchValue: this._matchValue! + } + }; + } + return { $expr: { format: this._format!, @@ -100,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -107,10 +185,17 @@ export class ReferenceExpression { if (this._handle) { return `ReferenceExpression(handle)`; } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } return `ReferenceExpression(${this._format})`; } } +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. @@ -136,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -307,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -466,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/transport.ts index 7bddd74beff..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -213,6 +354,76 @@ export class CapabilityError extends Error { } } +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + } +} + +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 // ============================================================================ @@ -324,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -346,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -361,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -381,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -411,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -422,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -432,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + 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; - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + let settled = false; - this.socket = net.createConnection(pipePath); + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -475,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -533,39 +935,66 @@ export class AspireClient { throw new Error('Not connected to AppHost'); } - // 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++; + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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++; - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + 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 { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/apphost.ts index b5024a7e975..bf900629390 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/apphost.ts @@ -18,6 +18,8 @@ await containerCache.runAsContainer({ const _connectionString = await cache.connectionStringExpression.get(); const _hostName = await cache.hostName.get(); +const _nameOutputReference = await cache.nameOutputReference.get(); +const _resourceId = await cache.id.get(); const _port = await cache.port.get(); const _uri = await cache.uriExpression.get(); const _useAccessKeyAuthentication: boolean = await cache.useAccessKeyAuthentication.get(); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..84f2fb3f0cd --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Redis/ValidationAppHost/aspire.config.json @@ -0,0 +1,10 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "packages": { + "Aspire.Hosting.Azure.KeyVault": "", + "Aspire.Hosting.Azure.Redis": "" + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.aspire/settings.json deleted file mode 100644 index 019aedb9788..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.aspire/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", - "packages": { - "Aspire.Hosting.Azure.ServiceBus": "" - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/.codegen-hash index 0d3f72e67bd..72037b14979 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -08113C594C5AD2D96D8F84CF78DA8618B17467BE3412D975974656BFF89EBBEA \ No newline at end of file +09CC07DA87355F1FA6EE67E88F781DA2EBB47B592D0A72E39DD5396FECD848B6 \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/aspire.ts index 0151f6cf553..5a8287b6076 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/aspire.ts @@ -8,6 +8,8 @@ import { AspireClient as AspireClientRpc, Handle, MarshalledHandle, + AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -65,9 +67,21 @@ type BicepOutputReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Az /** Handle to IAzureKeyVaultSecretReference */ type IAzureKeyVaultSecretReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultSecretReference'>; +/** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -77,6 +91,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -101,6 +118,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -131,15 +151,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -164,18 +196,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -188,12 +235,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -254,6 +307,7 @@ export enum EndpointProperty { Scheme = "Scheme", TargetPort = "TargetPort", HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", } /** Enum type for IconVariant */ @@ -329,6 +383,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for AzureServiceBusCorrelationFilter */ export interface AzureServiceBusCorrelationFilter { properties?: AspireDict; @@ -380,6 +440,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -406,7 +487,7 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } -export interface AddContainerRegistry1Options { +export interface AddContainerRegistryFromStringOptions { repository?: string; } @@ -419,16 +500,21 @@ export interface AddDockerfileOptions { stage?: string; } -export interface AddParameter1Options { - publishValueAsDefault?: boolean; +export interface AddParameterFromConfigurationOptions { secret?: boolean; } -export interface AddParameterFromConfigurationOptions { +export interface AddParameterOptions { secret?: boolean; } -export interface AddParameterOptions { +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; secret?: boolean; } @@ -452,22 +538,88 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; } export interface RunAsEmulatorOptions { configureContainer?: (obj: AzureServiceBusEmulatorResource) => Promise; } +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + export interface RunOptions { - cancellationToken?: AbortSignal; + 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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithBindMountOptions { isReadOnly?: boolean; } @@ -476,6 +628,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDescriptionOptions { enableMarkdown?: boolean; } @@ -569,6 +727,7 @@ export interface WithPipelineStepFactoryOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -588,6 +747,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -629,6 +825,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -703,11 +973,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -722,6 +993,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -739,9 +1069,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -815,6 +1145,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -837,6 +1178,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -850,6 +1255,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -916,6 +1332,16 @@ export class EndpointReference { }, }; + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { @@ -970,13 +1396,22 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs ); } + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + 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 + ); + } + } /** @@ -997,6 +1432,11 @@ export class EndpointReferencePromise implements PromiseLike return this._promise.then(obj => obj.getValueAsync(options)); } + /** 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 { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + } // ============================================================================ @@ -1074,11 +1514,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1108,6 +1571,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1126,16 +1600,17 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; @@ -1143,35 +1618,127 @@ export class ExecuteCommandContext { } // ============================================================================ -// PipelineConfigurationContext +// InitializeResourceEvent // ============================================================================ /** - * Type class for PipelineConfigurationContext. + * Type class for InitializeResourceEvent. */ -export class PipelineConfigurationContext { - constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Steps property */ - steps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, - set: async (value: PipelineStep[]): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', - { context: this._handle, value } - ); - } }; - /** Gets pipeline steps with the specified tag */ + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + { context: this._handle } + ); + }, + set: async (value: PipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } + ); + } + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; return await this._client.invokeCapability( @@ -1202,6 +1769,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1289,6 +1943,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1359,6 +2024,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1370,18 +2068,159 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; } +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + +} + // ============================================================================ // ProjectResourceOptions // ============================================================================ @@ -1564,86 +2403,381 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new ServiceProvider(handle, this._client); }, }; } // ============================================================================ -// DistributedApplicationBuilder +// ResourceLoggerService // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for ResourceLoggerService. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, + /** Completes the log stream for a resource */ + /** @internal */ + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + } + + /** Completes the log stream by resource name */ + /** @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 ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); + } + + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ + /** @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 ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + } + + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** Waits for all dependencies of a resource to be ready */ + /** @internal */ + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + } + + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ + /** @internal */ + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, }; - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); }, }; @@ -1651,654 +2785,1759 @@ export class DistributedApplicationBuilder { executionContext = { get: async (): Promise => { const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', { context: this._handle } ); return new DistributedApplicationExecutionContext(handle, this._client); }, }; - /** Builds the distributed application */ - /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', rpcArgs ); - return new DistributedApplication(result, this._client); } - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); } - /** Adds a connection string with a reference expression */ - /** @internal */ - async _addConnectionString1Internal(name: string, connectionStringExpression: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringExpression', + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionString1Internal(name, connectionStringExpression)); + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); } - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', + /** Checks whether a configuration section exists */ + 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. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + 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 ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @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 ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @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 DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @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 ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @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 ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds an Azure Service Bus namespace resource */ + /** @internal */ + async _addAzureServiceBusInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.ServiceBus/addAzureServiceBus', + rpcArgs + ); + return new AzureServiceBusResource(result, this._client); + } + + addAzureServiceBus(name: string): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._addAzureServiceBusInternal(name)); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds an Azure Service Bus namespace resource */ + addAzureServiceBus(name: string): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.addAzureServiceBus(name))); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); - } - - /** Adds a container registry resource */ - /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistry', + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', rpcArgs ); - return new ContainerRegistryResource(result, this._client); } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); } - /** Adds a container registry with string endpoint */ - /** @internal */ - async _addContainerRegistry1Internal(name: string, endpoint: string, repository?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistryFromString', + /** Checks if the environment matches the specified name */ + async isEnvironment(environmentName: string): Promise { + const rpcArgs: Record = { environment: this._handle, environmentName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isEnvironment', rpcArgs ); - return new ContainerRegistryResource(result, this._client); } - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistry1Internal(name, endpoint, repository)); +} + +/** + * Thenable wrapper for HostEnvironment that enables fluent chaining. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds a container resource */ - /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', - rpcArgs - ); - return new ContainerResource(result, this._client); + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); } - /** Adds a container resource built from a Dockerfile */ - /** @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 ContainerResource(result, this._client); + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); } - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); } - /** Adds a .NET tool resource */ +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ /** @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', + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', rpcArgs ); - return new DotnetToolResource(result, this._client); + return this; } - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._logInformationInternal(message)); } - /** Adds an executable resource */ + /** Logs a warning message */ /** @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', + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', rpcArgs ); - return new ExecutableResource(result, this._client); + return this; } - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._logWarningInternal(message)); } - /** Adds an external service resource */ + /** Logs an error message */ /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + logError(message: string): LoggerPromise { + return new LoggerPromise(this._logErrorInternal(message)); } - /** Adds an external service with a URI */ + /** Logs a debug message */ /** @internal */ - async _addExternalService2Internal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceUri', + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService2Internal(name, uri)); + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._logDebugInternal(message)); } - /** Adds an external service with a parameter URL */ + /** Logs a message with specified level */ /** @internal */ - async _addExternalService1Internal(name: string, urlParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, urlParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceParameter', + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService1Internal(name, urlParameter)); + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._logInternal(level, message)); } - /** Adds a parameter resource */ - /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', - rpcArgs - ); - return new ParameterResource(result, this._client); +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); } - /** Adds a parameter with a default value */ - /** @internal */ - async _addParameter1Internal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameterWithValue', - rpcArgs - ); - return new ParameterResource(result, this._client); + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); } - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - const publishValueAsDefault = options?.publishValueAsDefault; - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameter1Internal(name, value, publishValueAsDefault, secret)); + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); } - /** Adds a parameter sourced from configuration */ - /** @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 ParameterResource(result, this._client); + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); } - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); } - /** Adds a connection string resource */ +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', rpcArgs ); - return new ResourceWithConnectionString(result, this._client); + return new Logger(result, this._client); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); } - /** Adds a .NET project resource */ - /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', - rpcArgs - ); - return new ProjectResource(result, this._client); +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); } - /** Adds a project resource with configuration options */ +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', + 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 ProjectResource(result, this._client); + return new ReportingTask(result, this._client); } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); } - /** Adds a C# application resource */ + /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + 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 ProjectResource(result, this._client); + return new ReportingTask(result, this._client); } - - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); - } - - /** Adds a C# application resource with configuration options */ - /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', + + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); + } + + /** Logs a plain-text message for the reporting step */ + /** @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 new CSharpAppResource(result, this._client); + return this; } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); } - /** Adds an Azure Service Bus namespace resource */ + /** Logs a Markdown-formatted message for the reporting step */ /** @internal */ - async _addAzureServiceBusInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.ServiceBus/addAzureServiceBus', + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', rpcArgs ); - return new AzureServiceBusResource(result, this._client); + return this; } - addAzureServiceBus(name: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._addAzureServiceBusInternal(name)); + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); } - /** Adds an Azure Bicep template resource from a file */ + /** Completes the reporting step with plain-text completion text */ /** @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', + 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 new AzureBicepResource(result, this._client); + return this; } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); } - /** Adds an Azure Bicep template resource from inline Bicep content */ + /** Completes the reporting step with Markdown-formatted completion text */ /** @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', + 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 new AzureBicepResource(result, this._client); + return this; } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } - /** Adds an Azure provisioning resource to the application model */ +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); + } + + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); + } + + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); + } + + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); + } + + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ /** @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 AzureResourceInfrastructure(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', + 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 new AzureProvisioningResource(result, this._client); + return this; } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); } - /** Adds Azure provisioning services to the distributed application builder */ + /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _addAzureProvisioningInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', + 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 new DistributedApplicationBuilder(result, this._client); + return this; } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } - /** Adds the shared Azure environment resource to the application model */ + /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + 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 new AzureEnvironmentResource(result, this._client); + return this; } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } - /** Adds an Azure user-assigned identity resource */ + /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _addAzureUserAssignedIdentityInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + 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 new AzureUserAssignedIdentityResource(result, this._client); + return this; } - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); } - /** Adds a connection string with a reference expression */ - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionString1(name, connectionStringExpression))); + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } - /** Adds a container registry with string endpoint */ - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry1(name, endpoint, options))); - } +} - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); +// ============================================================================ +// ServiceProvider +// ============================================================================ + +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); } - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); } - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); } - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); } - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); } - /** Adds an external service with a URI */ - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService2(name, uri))); + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); } - /** Adds an external service with a parameter URL */ - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService1(name, urlParameter))); + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); } - /** Adds a parameter with a default value */ - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter1(name, value, options))); + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); +} + +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); } - /** Adds an Azure Service Bus namespace resource */ - addAzureServiceBus(name: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.addAzureServiceBus(name))); + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); } - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); +} + +// ============================================================================ +// UserSecretsManager +// ============================================================================ + +/** + * Type class for UserSecretsManager. + */ +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + /** Saves state to user secrets from a JSON string */ + /** @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; } - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); } -} - -// ============================================================================ -// DistributedApplicationEventing -// ============================================================================ - -/** - * Type class for DistributedApplicationEventing. - */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Invokes the Unsubscribe method */ + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; await this._client.invokeCapability( - 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', + 'Aspire.Hosting/getOrSetSecret', rpcArgs ); return this; } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } /** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } @@ -2523,11 +4762,26 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2542,7 +4796,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2585,36 +4839,6 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureBicepResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -2692,6 +4916,86 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -2707,6 +5011,135 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -2756,23 +5189,9 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -2781,28 +5200,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -2811,13 +5217,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -2826,8 +5234,9 @@ export class AzureBicepResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -2927,16 +5341,6 @@ export class AzureBicepResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -2957,11 +5361,76 @@ export class AzureBicepResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); } + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -2982,29 +5451,19 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -3229,11 +5688,26 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3248,7 +5722,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3291,36 +5765,6 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -3398,6 +5842,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -3520,6 +6044,11 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3540,16 +6069,6 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -3570,6 +6089,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -3807,11 +6346,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -3826,7 +6380,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -3869,36 +6423,6 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -3942,38 +6466,118 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureProvisioningResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureProvisioningResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -4120,6 +6724,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -4169,23 +6793,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -4194,28 +6804,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -4224,13 +6821,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -4239,8 +6838,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4340,16 +6945,6 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -4370,6 +6965,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -4420,6 +7035,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -4440,29 +7060,19 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -4680,7 +7290,7 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -4689,8 +7299,8 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -4709,6 +7319,27 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { + 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 AzureServiceBusEmulatorResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureServiceBusEmulatorResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new AzureServiceBusEmulatorResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -4840,41 +7471,11 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureServiceBusEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new AzureServiceBusEmulatorResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -4885,43 +7486,38 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase Promise): AzureServiceBusEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -5010,52 +7606,39 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureServiceBusEmulatorResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzureServiceBusEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new AzureServiceBusEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureServiceBusEmulatorResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzureServiceBusEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -5355,7 +7938,7 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -5385,7 +7968,7 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -5431,7 +8014,7 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -5536,7 +8119,7 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -5563,11 +8146,26 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureServiceBusEmulatorResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -5582,7 +8180,7 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -5721,63 +8319,163 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureServiceBusEmulatorResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureServiceBusEmulatorResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** @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 AzureServiceBusEmulatorResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): AzureServiceBusEmulatorResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new AzureServiceBusEmulatorResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureServiceBusEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureServiceBusEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); } /** @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; + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withVolume', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); } - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): AzureServiceBusEmulatorResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new AzureServiceBusEmulatorResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureServiceBusEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -5861,7 +8559,7 @@ export class AzureServiceBusEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new AzureServiceBusEmulatorResource(result, this._client); @@ -5954,8 +8652,8 @@ export class AzureServiceBusEmulatorResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureServiceBusEmulatorResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -5964,6 +8662,11 @@ export class AzureServiceBusEmulatorResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -6004,31 +8707,21 @@ export class AzureServiceBusEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureServiceBusEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -6054,21 +8747,16 @@ export class AzureServiceBusEmulatorResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureServiceBusEmulatorResourcePromise { - return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -6214,6 +8902,11 @@ export class AzureServiceBusEmulatorResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6274,6 +8967,31 @@ export class AzureServiceBusEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusEmulatorResourcePromise { + return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets the emulator configuration file path */ withConfigurationFile(path: string): AzureServiceBusEmulatorResourcePromise { return new AzureServiceBusEmulatorResourcePromise(this._promise.then(obj => obj.withConfigurationFile(path))); @@ -6331,6 +9049,27 @@ export class AzureServiceBusQueueResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureServiceBusQueueResource.parent', + { context: this._handle } + ); + return new AzureServiceBusResource(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureServiceBusQueueResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + /** Gets the DeadLetteringOnMessageExpiration property */ deadLetteringOnMessageExpiration = { get: async (): Promise => { @@ -6537,7 +9276,7 @@ export class AzureServiceBusQueueResource extends ResourceBuilderBase { + 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', @@ -6546,8 +9285,8 @@ export class AzureServiceBusQueueResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -6726,11 +9474,26 @@ export class AzureServiceBusQueueResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureServiceBusQueueResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureServiceBusQueueResource(result, this._client); @@ -6745,7 +9508,7 @@ export class AzureServiceBusQueueResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureServiceBusQueueResource(result, this._client); @@ -6788,36 +9551,6 @@ export class AzureServiceBusQueueResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureServiceBusQueueResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusQueueResourcePromise { - return new AzureServiceBusQueueResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureServiceBusQueueResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusQueueResourcePromise { - return new AzureServiceBusQueueResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -6895,6 +9628,106 @@ export class AzureServiceBusQueueResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureServiceBusQueueResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureServiceBusQueueResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureServiceBusQueueResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureServiceBusQueueResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureServiceBusQueueResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withPropertiesInternal(configure: (obj: AzureServiceBusQueueResource) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { @@ -6962,8 +9795,8 @@ export class AzureServiceBusQueueResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureServiceBusQueueResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureServiceBusQueueResourcePromise { return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -6972,6 +9805,11 @@ export class AzureServiceBusQueueResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureServiceBusQueueResourcePromise { return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -7017,6 +9855,11 @@ export class AzureServiceBusQueueResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureServiceBusQueueResourcePromise { return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -7037,16 +9880,6 @@ export class AzureServiceBusQueueResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusQueueResourcePromise { - return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusQueueResourcePromise { - return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureServiceBusQueueResourcePromise { return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -7067,6 +9900,31 @@ export class AzureServiceBusQueueResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusQueueResourcePromise { + return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Configures properties of an Azure Service Bus queue */ withProperties(configure: (obj: AzureServiceBusQueueResource) => Promise): AzureServiceBusQueueResourcePromise { return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.withProperties(configure))); @@ -7159,7 +10017,7 @@ export class AzureServiceBusResource extends ResourceBuilderBase { + 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', @@ -7168,8 +10026,8 @@ export class AzureServiceBusResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -7509,11 +10376,26 @@ export class AzureServiceBusResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureServiceBusResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureServiceBusResource(result, this._client); @@ -7528,7 +10410,7 @@ export class AzureServiceBusResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureServiceBusResource(result, this._client); @@ -7567,67 +10449,37 @@ export class AzureServiceBusResource extends ResourceBuilderBase( - 'Aspire.Hosting/withHttpProbe', - rpcArgs - ); - return new AzureServiceBusResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureServiceBusResourcePromise { - 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 AzureServiceBusResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new AzureServiceBusResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + 'Aspire.Hosting/withHttpProbe', rpcArgs ); return new AzureServiceBusResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureServiceBusResourcePromise { + 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 AzureServiceBusResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new AzureServiceBusResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ @@ -7707,6 +10559,126 @@ export class AzureServiceBusResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureServiceBusResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureServiceBusResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureServiceBusResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureServiceBusResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureServiceBusResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureServiceBusResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _addServiceBusQueueInternal(name: string, queueName?: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -7976,23 +10948,9 @@ export class AzureServiceBusResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureServiceBusResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -8001,28 +10959,15 @@ export class AzureServiceBusResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureServiceBusResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -8031,13 +10976,15 @@ export class AzureServiceBusResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -8046,8 +10993,9 @@ export class AzureServiceBusResource extends ResourceBuilderBase obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureServiceBusResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureServiceBusResourcePromise { return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -8097,6 +11045,11 @@ export class AzureServiceBusResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): AzureServiceBusResourcePromise { return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -8182,6 +11135,11 @@ export class AzureServiceBusResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureServiceBusResourcePromise { return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -8207,16 +11165,6 @@ export class AzureServiceBusResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureServiceBusResourcePromise { return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -8237,6 +11185,36 @@ export class AzureServiceBusResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Adds an Azure Service Bus queue resource */ addServiceBusQueue(name: string, options?: AddServiceBusQueueOptions): AzureServiceBusQueueResourcePromise { return new AzureServiceBusQueueResourcePromise(this._promise.then(obj => obj.addServiceBusQueue(name, options))); @@ -8327,29 +11305,19 @@ export class AzureServiceBusResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureServiceBusResourcePromise { - return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureServiceBusResourcePromise { + return new AzureServiceBusResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -8379,6 +11347,27 @@ export class AzureServiceBusSubscriptionResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureServiceBusSubscriptionResource.parent', + { context: this._handle } + ); + return new AzureServiceBusTopicResource(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureServiceBusSubscriptionResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + /** Gets the DeadLetteringOnMessageExpiration property */ deadLetteringOnMessageExpiration = { get: async (): Promise => { @@ -8567,7 +11556,7 @@ export class AzureServiceBusSubscriptionResource extends ResourceBuilderBase { + 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', @@ -8576,8 +11565,8 @@ export class AzureServiceBusSubscriptionResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -8756,11 +11754,26 @@ export class AzureServiceBusSubscriptionResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureServiceBusSubscriptionResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureServiceBusSubscriptionResource(result, this._client); @@ -8775,7 +11788,7 @@ export class AzureServiceBusSubscriptionResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureServiceBusSubscriptionResource(result, this._client); @@ -8818,36 +11831,6 @@ export class AzureServiceBusSubscriptionResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureServiceBusSubscriptionResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusSubscriptionResourcePromise { - return new AzureServiceBusSubscriptionResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureServiceBusSubscriptionResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusSubscriptionResourcePromise { - return new AzureServiceBusSubscriptionResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -8905,24 +11888,124 @@ export class AzureServiceBusSubscriptionResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/withPipelineConfiguration', + rpcArgs + ); + return new AzureServiceBusSubscriptionResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureServiceBusSubscriptionResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureServiceBusSubscriptionResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureServiceBusSubscriptionResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureServiceBusSubscriptionResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureServiceBusSubscriptionResourcePromise { - return new AzureServiceBusSubscriptionResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._onInitializeResourceInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureServiceBusSubscriptionResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -8992,8 +12075,8 @@ export class AzureServiceBusSubscriptionResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureServiceBusSubscriptionResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureServiceBusSubscriptionResourcePromise { return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -9002,6 +12085,11 @@ export class AzureServiceBusSubscriptionResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureServiceBusSubscriptionResourcePromise { return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -9047,6 +12135,11 @@ export class AzureServiceBusSubscriptionResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureServiceBusSubscriptionResourcePromise { return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9067,16 +12160,6 @@ export class AzureServiceBusSubscriptionResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusSubscriptionResourcePromise { - return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusSubscriptionResourcePromise { - return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureServiceBusSubscriptionResourcePromise { return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -9097,6 +12180,31 @@ export class AzureServiceBusSubscriptionResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusSubscriptionResourcePromise { + return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Configures properties of an Azure Service Bus subscription */ withProperties(configure: (obj: AzureServiceBusSubscriptionResource) => Promise): AzureServiceBusSubscriptionResourcePromise { return new AzureServiceBusSubscriptionResourcePromise(this._promise.then(obj => obj.withProperties(configure))); @@ -9134,6 +12242,27 @@ export class AzureServiceBusTopicResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureServiceBusTopicResource.parent', + { context: this._handle } + ); + return new AzureServiceBusResource(handle, this._client); + }, + }; + + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureServiceBusTopicResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; + /** Gets the DefaultMessageTimeToLive property */ defaultMessageTimeToLive = { get: async (): Promise => { @@ -9244,7 +12373,7 @@ export class AzureServiceBusTopicResource extends ResourceBuilderBase { + 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', @@ -9253,8 +12382,8 @@ export class AzureServiceBusTopicResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -9433,11 +12571,26 @@ export class AzureServiceBusTopicResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureServiceBusTopicResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureServiceBusTopicResource(result, this._client); @@ -9452,7 +12605,7 @@ export class AzureServiceBusTopicResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureServiceBusTopicResource(result, this._client); @@ -9495,36 +12648,6 @@ export class AzureServiceBusTopicResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureServiceBusTopicResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusTopicResourcePromise { - return new AzureServiceBusTopicResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureServiceBusTopicResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusTopicResourcePromise { - return new AzureServiceBusTopicResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -9602,6 +12725,106 @@ export class AzureServiceBusTopicResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureServiceBusTopicResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureServiceBusTopicResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureServiceBusTopicResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureServiceBusTopicResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureServiceBusTopicResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withPropertiesInternal(configure: (obj: AzureServiceBusTopicResource) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { @@ -9686,8 +12909,8 @@ export class AzureServiceBusTopicResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureServiceBusTopicResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureServiceBusTopicResourcePromise { return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -9696,6 +12919,11 @@ export class AzureServiceBusTopicResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureServiceBusTopicResourcePromise { return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -9741,6 +12969,11 @@ export class AzureServiceBusTopicResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureServiceBusTopicResourcePromise { return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9761,16 +12994,6 @@ export class AzureServiceBusTopicResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureServiceBusTopicResourcePromise { - return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureServiceBusTopicResourcePromise { - return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureServiceBusTopicResourcePromise { return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -9791,6 +13014,31 @@ export class AzureServiceBusTopicResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureServiceBusTopicResourcePromise { + return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Configures properties of an Azure Service Bus topic */ withProperties(configure: (obj: AzureServiceBusTopicResource) => Promise): AzureServiceBusTopicResourcePromise { return new AzureServiceBusTopicResourcePromise(this._promise.then(obj => obj.withProperties(configure))); @@ -10028,11 +13276,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -10047,7 +13310,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -10091,110 +13354,160 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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 PipelineStepContext(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/withRemoteImageName', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a pipeline step to the resource */ + 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 AzureUserAssignedIdentityResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onResourceStopped', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 AzureUserAssignedIdentityResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -10410,23 +13723,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -10435,28 +13734,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -10465,13 +13751,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -10480,8 +13768,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -10581,16 +13875,6 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -10611,6 +13895,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -10686,29 +13990,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -10774,7 +14068,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -10783,8 +14077,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -10915,7 +14218,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -10945,7 +14248,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -10991,7 +14294,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -11040,11 +14343,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -11059,7 +14377,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -11102,36 +14420,6 @@ export class ConnectionStringResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ConnectionStringResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -11209,6 +14497,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -11256,8 +14644,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -11266,6 +14654,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -11336,6 +14729,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -11356,16 +14754,6 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -11386,6 +14774,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -11614,95 +15027,80 @@ export class ContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - const iconVariant = options?.iconVariant; - return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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/withRemoteImageName', + 'Aspire.Hosting/withIconName', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ @@ -11782,6 +15180,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -11829,130 +15307,399 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Service Bus roles to a resource */ + withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export class ContainerResource extends ResourceBuilderBase { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageTagInternal(tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromise(this._withImageInternal(image, tag)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @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 ContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageSHA256Internal(sha256)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @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 ContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** @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 ContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._withLifetimeInternal(lifetime)); } - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @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 ContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsContainerInternal()); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** @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 ContainerResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** @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 ContainerResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); } - /** Assigns Service Bus roles to a resource */ - withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); + /** @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 ContainerResource(result, this._client); } -} - -// ============================================================================ -// ContainerResource -// ============================================================================ - -export class ContainerResource extends ResourceBuilderBase { - constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + 'Aspire.Hosting/withEndpointProxySupport', rpcArgs ); return new ContainerResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } /** @internal */ @@ -11974,6 +15721,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -12024,58 +15786,43 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -12086,43 +15833,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -12211,52 +15953,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -12556,7 +16285,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -12586,7 +16315,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -12632,7 +16361,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -12737,7 +16466,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -12764,11 +16493,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -12783,7 +16527,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -12953,6 +16697,25 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -12962,6 +16725,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -13011,7 +16874,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ContainerResource(result, this._client); @@ -13044,11 +16907,96 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -13064,36 +17012,31 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -13119,21 +17062,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -13279,6 +17217,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -13329,11 +17272,41 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -13479,58 +17452,50 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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 CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironment', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -13541,43 +17506,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -13666,52 +17626,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -13996,7 +17943,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14026,7 +17973,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14056,7 +18003,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14102,7 +18049,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14207,7 +18154,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14234,11 +18181,26 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14253,7 +18215,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14432,6 +18394,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -14481,7 +18543,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -14544,36 +18606,31 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -14599,21 +18656,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -14764,6 +18816,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14819,6 +18876,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -15106,41 +19188,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -15151,43 +19203,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -15276,52 +19323,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -15621,7 +19655,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -15651,7 +19685,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -15697,7 +19731,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -15802,7 +19836,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -15829,11 +19863,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -15848,7 +19897,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -16013,18 +20062,118 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -16076,7 +20225,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -16184,31 +20333,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -16234,21 +20373,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -16394,6 +20528,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16449,6 +20588,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -16514,6 +20678,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -16581,41 +20810,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -16626,43 +20825,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -16751,52 +20945,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -17096,7 +21277,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -17126,7 +21307,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -17172,7 +21353,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -17277,7 +21458,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -17304,11 +21485,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -17323,7 +21519,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -17454,52 +21650,152 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -17551,7 +21847,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ExecutableResource(result, this._client); @@ -17589,6 +21885,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -17609,31 +21925,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -17659,21 +21965,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -17819,6 +22120,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -17874,6 +22180,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -18135,11 +22466,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -18154,7 +22500,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -18197,36 +22543,6 @@ export class ExternalServiceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ExternalServiceResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -18304,6 +22620,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -18401,6 +22797,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18421,16 +22822,6 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -18451,6 +22842,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -18695,11 +23106,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -18714,7 +23140,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -18757,36 +23183,6 @@ export class ParameterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ParameterResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -18864,6 +23260,86 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -18961,6 +23437,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18981,16 +23462,6 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -19011,6 +23482,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -19111,74 +23602,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -19186,15 +23679,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -19212,6 +23705,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -19298,52 +23806,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -19628,7 +24123,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -19658,7 +24153,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -19688,7 +24183,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -19734,7 +24229,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -19839,7 +24334,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -19866,11 +24361,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -19885,7 +24395,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -20064,6 +24574,106 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -20113,7 +24723,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ProjectResource(result, this._client); @@ -20166,29 +24776,29 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -20196,6 +24806,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -20221,21 +24836,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -20386,6 +24996,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -20441,6 +25056,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -20521,23 +25161,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -20546,28 +25172,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -20576,13 +25189,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -20591,8 +25206,9 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -20632,29 +25248,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -20668,11 +25274,41 @@ export class ComputeResource extends ResourceBuilderBase super(handle, 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 ComputeResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ComputeResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + /** @internal */ private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ComputeResource(result, this._client); @@ -20700,6 +25336,16 @@ export class ComputeResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + /** Associates an Azure user-assigned identity with a compute resource */ withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): ComputeResourcePromise { return new ComputeResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); @@ -20720,7 +25366,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -20975,11 +25621,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -20994,7 +25655,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -21037,36 +25698,6 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._excludeFromMcpInternal()); } - /** @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 Resource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 Resource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -21144,6 +25775,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withServiceBusRoleAssignmentsInternal(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -21236,6 +25947,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -21256,16 +25972,6 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -21286,6 +25992,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Service Bus roles to a resource */ withServiceBusRoleAssignments(target: AzureServiceBusResource, roles: AzureServiceBusRole[]): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withServiceBusRoleAssignments(target, roles))); @@ -21401,7 +26127,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -21410,8 +26136,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -21447,8 +26202,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -21457,6 +26212,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -21745,6 +26510,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -21812,6 +26597,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -21854,41 +26644,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -21899,43 +26659,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -21969,52 +26724,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -22097,7 +26839,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -22181,31 +26923,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -22216,21 +26948,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -22278,34 +27005,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -22319,7 +27018,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -22349,7 +27048,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -22380,7 +27079,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -22499,7 +27198,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { const error = reason instanceof Error ? reason : new Error(String(reason)); - if (reason instanceof CapabilityError) { + 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) { @@ -22530,8 +27231,12 @@ process.on('unhandledRejection', (reason: unknown) => { }); process.on('uncaughtException', (error: Error) => { - console.error(`\n❌ Uncaught Exception: ${error.message}`); - if (error.stack) { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + if (!(error instanceof AppHostUsageError) && error.stack) { console.error(error.stack); } process.exit(1); @@ -22542,23 +27247,46 @@ process.on('uncaughtException', (error: Error) => { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource', (handle, client) => new AzureEnvironmentResource(handle as AzureEnvironmentResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureProvisioningResource', (handle, client) => new AzureProvisioningResource(handle as AzureProvisioningResourceHandle, client)); @@ -22586,6 +27314,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/base.ts index 7778b0f1737..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -43,22 +43,46 @@ export class ReferenceExpression { private readonly _format?: string; private readonly _valueProviders?: unknown[]; + // Conditional mode fields + private readonly _condition?: unknown; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; + private readonly _matchValue?: string; + // Handle mode fields (when wrapping a server-returned handle) private readonly _handle?: Handle; private readonly _client?: AspireClient; constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(handleOrFormat: Handle | string, clientOrValueProviders: AspireClient | unknown[]) { - if (typeof handleOrFormat === 'string') { - this._format = handleOrFormat; - this._valueProviders = clientOrValueProviders as unknown[]; + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression + ) { + if (typeof handleOrFormatOrCondition === 'string') { + this._format = handleOrFormatOrCondition; + this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (handleOrFormatOrCondition instanceof Handle) { + this._handle = handleOrFormatOrCondition; + this._client = clientOrValueProvidersOrMatchValue as AspireClient; } else { - this._handle = handleOrFormat; - this._client = clientOrValueProviders as AspireClient; + this._condition = handleOrFormatOrCondition; + this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + this._whenTrue = whenTrueOrWhenFalse; + this._whenFalse = whenFalse; } } + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return this._condition !== undefined; + } + /** * Creates a reference expression from a tagged template literal. * @@ -82,16 +106,46 @@ export class ReferenceExpression { return new ReferenceExpression(format, valueProviders); } + /** + * Creates a conditional reference expression from its constituent parts. + * + * @param condition - A value provider whose result is compared to matchValue + * @param whenTrue - The expression to use when the condition matches + * @param whenFalse - The expression to use when the condition does not match + * @param matchValue - The value to compare the condition against (defaults to "True") + * @returns A ReferenceExpression instance in conditional mode + */ + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression { + return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + } + /** * Serializes the reference expression for JSON-RPC transport. - * In template-literal mode, uses the $expr format. + * 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[] } } | MarshalledHandle { + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { if (this._handle) { return this._handle.toJSON(); } + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(this._condition), + whenTrue: this._whenTrue!.toJSON(), + whenFalse: this._whenFalse!.toJSON(), + matchValue: this._matchValue! + } + }; + } + return { $expr: { format: this._format!, @@ -100,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -107,10 +185,17 @@ export class ReferenceExpression { if (this._handle) { return `ReferenceExpression(handle)`; } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } return `ReferenceExpression(${this._format})`; } } +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. @@ -136,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -307,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -466,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/transport.ts index 7bddd74beff..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -213,6 +354,76 @@ export class CapabilityError extends Error { } } +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + } +} + +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 // ============================================================================ @@ -324,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -346,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -361,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -381,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -411,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -422,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -432,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + 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; - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + let settled = false; - this.socket = net.createConnection(pipePath); + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -475,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -533,39 +935,66 @@ export class AspireClient { throw new Error('Not connected to AppHost'); } - // 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++; + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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++; - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + 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 { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/apphost.ts index 3c4e126b0c1..24c81fb368c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/apphost.ts @@ -39,6 +39,13 @@ const subscription = await topic.addServiceBusSubscription("audit", { subscriptionName: "audit-sub", }); +const _queueParent = await queue.parent.get(); +const _queueConnectionString = await queue.connectionStringExpression.get(); +const _topicParent = await topic.parent.get(); +const _topicConnectionString = await topic.connectionStringExpression.get(); +const _subscriptionParent = await subscription.parent.get(); +const _subscriptionConnectionString = await subscription.connectionStringExpression.get(); + // ── DTO types ─────────────────────────────────────────────────────────────── const filter: AzureServiceBusCorrelationFilter = { correlationId: "order-123", diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..ca5e1feeaad --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/aspire.config.json @@ -0,0 +1,9 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "packages": { + "Aspire.Hosting.Azure.ServiceBus": "" + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.aspire/settings.json deleted file mode 100644 index ce3c664adf4..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.aspire/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", - "packages": { - "Aspire.Hosting.Azure.Sql": "", - "Aspire.Hosting.Azure.Storage": "" - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/.codegen-hash index 18aa7c77f86..97aa563455f 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -A37E8539B7887A89887D18838C78EA578BCD65939A3E2395CA3A6FC7427F8C67 \ No newline at end of file +08049311E4B82DC3E9899ED89CD637794DE86050867CF0E306D9EAA46424498B \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/aspire.ts index 3a97562eb3a..8fb73c41337 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/aspire.ts @@ -8,6 +8,8 @@ import { AspireClient as AspireClientRpc, Handle, MarshalledHandle, + AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -26,6 +28,24 @@ import { // Handle Type Aliases (Internal - not exported to users) // ============================================================================ +/** Handle to AzureNatGatewayResource */ +type AzureNatGatewayResourceHandle = Handle<'Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureNatGatewayResource'>; + +/** Handle to AzureNetworkSecurityGroupResource */ +type AzureNetworkSecurityGroupResourceHandle = Handle<'Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureNetworkSecurityGroupResource'>; + +/** Handle to AzurePrivateEndpointResource */ +type AzurePrivateEndpointResourceHandle = Handle<'Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzurePrivateEndpointResource'>; + +/** Handle to AzurePublicIPAddressResource */ +type AzurePublicIPAddressResourceHandle = Handle<'Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzurePublicIPAddressResource'>; + +/** Handle to AzureSubnetResource */ +type AzureSubnetResourceHandle = Handle<'Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureSubnetResource'>; + +/** Handle to AzureVirtualNetworkResource */ +type AzureVirtualNetworkResourceHandle = Handle<'Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureVirtualNetworkResource'>; + /** Handle to AzureSqlDatabaseResource */ type AzureSqlDatabaseResourceHandle = Handle<'Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.AzureSqlDatabaseResource'>; @@ -80,18 +100,36 @@ type AzureUserAssignedIdentityResourceHandle = Handle<'Aspire.Hosting.Azure/Aspi /** Handle to BicepOutputReference */ type BicepOutputReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference'>; +/** Handle to IAzureDelegatedSubnetResource */ +type IAzureDelegatedSubnetResourceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureDelegatedSubnetResource'>; + /** Handle to IAzureKeyVaultSecretReference */ type IAzureKeyVaultSecretReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultSecretReference'>; +/** Handle to IAzurePrivateEndpointTarget */ +type IAzurePrivateEndpointTargetHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzurePrivateEndpointTarget'>; + /** Handle to SqlServerDatabaseResource */ type SqlServerDatabaseResourceHandle = Handle<'Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerDatabaseResource'>; /** Handle to SqlServerServerResource */ type SqlServerServerResourceHandle = Handle<'Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerServerResource'>; +/** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -101,6 +139,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -125,6 +166,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -155,15 +199,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -188,18 +244,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -212,12 +283,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -289,6 +366,7 @@ export enum EndpointProperty { Scheme = "Scheme", TargetPort = "TargetPort", HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", } /** Enum type for IconVariant */ @@ -348,6 +426,28 @@ export enum ProtocolType { Unknown = "Unknown", } +/** Enum type for SecurityRuleAccess */ +export enum SecurityRuleAccess { + Allow = "Allow", + Deny = "Deny", +} + +/** Enum type for SecurityRuleDirection */ +export enum SecurityRuleDirection { + Inbound = "Inbound", + Outbound = "Outbound", +} + +/** Enum type for SecurityRuleProtocol */ +export enum SecurityRuleProtocol { + Tcp = "Tcp", + Udp = "Udp", + Icmp = "Icmp", + Esp = "Esp", + Asterisk = "Asterisk", + Ah = "Ah", +} + /** Enum type for UrlDisplayLocation */ export enum UrlDisplayLocation { SummaryAndDetails = "SummaryAndDetails", @@ -364,6 +464,28 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + +/** DTO interface for AzureSecurityRule */ +export interface AzureSecurityRule { + name?: string; + description?: string; + priority?: number; + direction?: SecurityRuleDirection; + access?: SecurityRuleAccess; + protocol?: SecurityRuleProtocol; + sourceAddressPrefix?: string; + sourceAddressPrefixReference?: ReferenceExpression; + sourcePortRange?: string; + destinationAddressPrefix?: string; + destinationAddressPrefixReference?: ReferenceExpression; + destinationPortRange?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -394,6 +516,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -416,6 +559,10 @@ export interface ResourceUrlAnnotation { // Options Interfaces // ============================================================================ +export interface AddAzureVirtualNetworkOptions { + addressPrefix?: string; +} + export interface AddBlobContainerOptions { blobContainerName?: string; } @@ -424,7 +571,7 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } -export interface AddContainerRegistry1Options { +export interface AddContainerRegistryFromStringOptions { repository?: string; } @@ -445,16 +592,21 @@ export interface AddDockerfileOptions { stage?: string; } -export interface AddParameter1Options { - publishValueAsDefault?: boolean; +export interface AddParameterFromConfigurationOptions { secret?: boolean; } -export interface AddParameterFromConfigurationOptions { +export interface AddParameterOptions { secret?: boolean; } -export interface AddParameterOptions { +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; secret?: boolean; } @@ -467,6 +619,28 @@ export interface AddSqlServerOptions { port?: number; } +export interface AddSubnetOptions { + subnetName?: string; +} + +export interface AllowInboundOptions { + port?: string; + from?: string; + to?: string; + protocol?: SecurityRuleProtocol; + priority?: number; + name?: string; +} + +export interface AllowOutboundOptions { + port?: string; + from?: string; + to?: string; + protocol?: SecurityRuleProtocol; + priority?: number; + name?: string; +} + export interface AppendFormattedOptions { format?: string; } @@ -475,8 +649,72 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface DenyInboundOptions { + port?: string; + from?: string; + to?: string; + protocol?: SecurityRuleProtocol; + priority?: number; + name?: string; +} + +export interface DenyOutboundOptions { + port?: string; + from?: string; + to?: string; + protocol?: SecurityRuleProtocol; + priority?: number; + name?: string; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; } export interface RunAsContainerOptions { @@ -487,14 +725,34 @@ export interface RunAsEmulatorOptions { configureContainer?: (obj: AzureStorageEmulatorResource) => Promise; } +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + export interface RunOptions { - cancellationToken?: AbortSignal; + 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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithApiVersionCheckOptions { enable?: boolean; } @@ -507,6 +765,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDataBindMountOptions { path?: string; isReadOnly?: boolean; @@ -610,6 +874,7 @@ export interface WithPipelineStepFactoryOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -629,6 +894,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -670,6 +972,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -744,11 +1120,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -763,6 +1140,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -780,9 +1216,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -856,6 +1292,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -878,6 +1325,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -891,6 +1402,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -957,6 +1479,16 @@ export class EndpointReference { }, }; + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { @@ -1011,15 +1543,24 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs ); } -} - + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + 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. */ @@ -1038,6 +1579,11 @@ export class EndpointReferencePromise implements PromiseLike return this._promise.then(obj => obj.getValueAsync(options)); } + /** 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 { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + } // ============================================================================ @@ -1115,11 +1661,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1149,6 +1718,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1167,22 +1747,93 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; } +// ============================================================================ +// InitializeResourceEvent +// ============================================================================ + +/** + * Type class for InitializeResourceEvent. + */ +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineConfigurationContext // ============================================================================ @@ -1196,6 +1847,17 @@ export class PipelineConfigurationContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the Steps property */ steps = { get: async (): Promise => { @@ -1212,6 +1874,17 @@ export class PipelineConfigurationContext { } }; + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; @@ -1243,6 +1916,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1330,6 +2090,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1400,6 +2171,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1411,18 +2215,159 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; } +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + +} + // ============================================================================ // ProjectResourceOptions // ============================================================================ @@ -1605,989 +2550,8785 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new ServiceProvider(handle, this._client); }, }; } // ============================================================================ -// DistributedApplicationBuilder +// ResourceLoggerService // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for ResourceLoggerService. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, - }; - - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', - { context: this._handle } - ); - return new DistributedApplicationEventing(handle, this._client); - }, - }; - - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', - { context: this._handle } - ); - return new DistributedApplicationExecutionContext(handle, this._client); - }, - }; - - /** Builds the distributed application */ + /** Completes the log stream for a resource */ /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', rpcArgs ); - return new DistributedApplication(result, this._client); + return this; } - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); } - /** Adds a connection string with a reference expression */ + /** Completes the log stream by resource name */ /** @internal */ - async _addConnectionString1Internal(name: string, connectionStringExpression: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringExpression', + async _completeLogByNameInternal(resourceName: string): Promise { + const rpcArgs: Record = { loggerService: this._handle, resourceName }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLogByName', rpcArgs ); - return new ConnectionStringResource(result, this._client); + return this; } - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionString1Internal(name, connectionStringExpression)); + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); } - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } +} - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); - } +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds a container registry resource */ - /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { - 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 ContainerRegistryResource(result, this._client); + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); } - /** Adds a container registry with string endpoint */ - /** @internal */ - async _addContainerRegistry1Internal(name: string, endpoint: string, repository?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistryFromString', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); } - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistry1Internal(name, endpoint, repository)); - } +} - /** Adds a container resource */ - /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', - rpcArgs - ); - return new ContainerResource(result, this._client); - } +// ============================================================================ +// ResourceNotificationService +// ============================================================================ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); - } +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} - /** Adds a container resource built from a Dockerfile */ + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ /** @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', + 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 new ContainerResource(result, this._client); + return this; } - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + const targetState = options?.targetState; + return new ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); } - /** Adds a .NET tool resource */ - /** @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', + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', rpcArgs ); - return new DotnetToolResource(result, this._client); - } - - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); } - /** Adds an executable resource */ - /** @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', + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', rpcArgs ); - return new ExecutableResource(result, this._client); - } - - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); } - /** Adds an external service resource */ + /** Waits for all dependencies of a resource to be ready */ /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); } - /** Adds an external service with a URI */ - /** @internal */ - async _addExternalService2Internal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceUri', + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', rpcArgs ); - return new ExternalServiceResource(result, this._client); - } - - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService2Internal(name, uri)); } - /** Adds an external service with a parameter URL */ + /** Publishes an update for a resource's state */ /** @internal */ - async _addExternalService1Internal(name: string, urlParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, urlParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceParameter', + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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 new ExternalServiceResource(result, this._client); + return this; } - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService1Internal(name, urlParameter)); + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); } - /** Adds a parameter resource */ - /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', - rpcArgs - ); - return new ParameterResource(result, this._client); - } +} - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); - } +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds a parameter with a default value */ - /** @internal */ - async _addParameter1Internal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameterWithValue', - rpcArgs - ); - return new ParameterResource(result, this._client); + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - const publishValueAsDefault = options?.publishValueAsDefault; - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameter1Internal(name, value, publishValueAsDefault, secret)); + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); } - /** Adds a parameter sourced from configuration */ - /** @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 ParameterResource(result, this._client); + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); } - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); } - /** Adds a connection string resource */ - /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', - rpcArgs - ); - return new ResourceWithConnectionString(result, this._client); + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); } - /** Adds a .NET project resource */ - /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', - rpcArgs - ); - return new ProjectResource(result, this._client); + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); - } +} - /** Adds a project resource with configuration options */ - /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', + rpcArgs + ); + } + + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); + } + + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', + rpcArgs + ); + } + + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); + } + + /** Checks whether a configuration section exists */ + 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. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + 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 ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @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 ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @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 DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @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 ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @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 ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; const obj = new ProjectResourceOptions(objHandle, this._client); await configure(obj); }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds an Azure NAT Gateway resource to the application model. */ + /** @internal */ + async _addNatGatewayInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/addNatGateway', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + addNatGateway(name: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._addNatGatewayInternal(name)); + } + + /** Adds an Azure Network Security Group resource to the application model. */ + /** @internal */ + async _addNetworkSecurityGroupInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/addNetworkSecurityGroup', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + addNetworkSecurityGroup(name: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._addNetworkSecurityGroupInternal(name)); + } + + /** Adds an Azure Public IP Address resource to the application model. */ + /** @internal */ + async _addPublicIPAddressInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/addPublicIPAddress', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); + } + + addPublicIPAddress(name: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._addPublicIPAddressInternal(name)); + } + + /** Adds an Azure Virtual Network resource to the application model. */ + /** @internal */ + async _addAzureVirtualNetworkInternal(name: string, addressPrefix?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (addressPrefix !== undefined) rpcArgs.addressPrefix = addressPrefix; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/addAzureVirtualNetwork', + rpcArgs + ); + return new AzureVirtualNetworkResource(result, this._client); + } + + addAzureVirtualNetwork(name: string, options?: AddAzureVirtualNetworkOptions): AzureVirtualNetworkResourcePromise { + const addressPrefix = options?.addressPrefix; + return new AzureVirtualNetworkResourcePromise(this._addAzureVirtualNetworkInternal(name, addressPrefix)); + } + + /** Adds an Azure SQL Database server resource */ + /** @internal */ + async _addAzureSqlServerInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Sql/addAzureSqlServer', + rpcArgs + ); + return new AzureSqlServerResource(result, this._client); + } + + addAzureSqlServer(name: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._addAzureSqlServerInternal(name)); + } + + /** Adds an Azure Storage resource */ + /** @internal */ + async _addAzureStorageInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addAzureStorage', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + addAzureStorage(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._addAzureStorageInternal(name)); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + + /** Adds a SQL Server container resource */ + /** @internal */ + async _addSqlServerInternal(name: string, password?: ParameterResource, port?: number): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (password !== undefined) rpcArgs.password = password; + if (port !== undefined) rpcArgs.port = port; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.SqlServer/addSqlServer', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { + const password = options?.password; + const port = options?.port; + return new SqlServerServerResourcePromise(this._addSqlServerInternal(name, password, port)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds an Azure NAT Gateway resource to the application model. */ + addNatGateway(name: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.addNatGateway(name))); + } + + /** Adds an Azure Network Security Group resource to the application model. */ + addNetworkSecurityGroup(name: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.addNetworkSecurityGroup(name))); + } + + /** Adds an Azure Public IP Address resource to the application model. */ + addPublicIPAddress(name: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.addPublicIPAddress(name))); + } + + /** Adds an Azure Virtual Network resource to the application model. */ + addAzureVirtualNetwork(name: string, options?: AddAzureVirtualNetworkOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.addAzureVirtualNetwork(name, options))); + } + + /** Adds an Azure SQL Database server resource */ + addAzureSqlServer(name: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.addAzureSqlServer(name))); + } + + /** Adds an Azure Storage resource */ + addAzureStorage(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.addAzureStorage(name))); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + + /** Adds a SQL Server container resource */ + addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.addSqlServer(name, options))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', + rpcArgs + ); + } + + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', + rpcArgs + ); + } + + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); + } + + /** Checks if the environment matches the specified name */ + 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. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); + } + + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); + } + + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); + } + + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); + } + +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ + /** @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 LoggerPromise(this._logInformationInternal(message)); + } + + /** Logs a warning message */ + /** @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 LoggerPromise(this._logWarningInternal(message)); + } + + /** Logs an error message */ + /** @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 LoggerPromise(this._logErrorInternal(message)); + } + + /** Logs a debug message */ + /** @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 LoggerPromise(this._logDebugInternal(message)); + } + + /** Logs a message with specified level */ + /** @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 LoggerPromise(this._logInternal(level, message)); + } + +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); + } + + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); + } + + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); + } + + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); + } + + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); + } + +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ + /** @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 Logger(result, this._client); + } + + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); + } + +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); + } + +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ + /** @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 ReportingTask(result, this._client); + } + + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); + } + + /** Creates a reporting task with Markdown-formatted status text */ + /** @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 ReportingTask(result, this._client); + } + + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); + } + + /** Logs a plain-text message for the reporting step */ + /** @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 ReportingStepPromise(this._logStepInternal(level, message)); + } + + /** Logs a Markdown-formatted message for the reporting step */ + /** @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 ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); + } + + /** Completes the reporting step with plain-text completion text */ + /** @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 ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + /** @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 ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); + } + +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); + } + + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); + } + + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); + } + + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); + } + + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ + /** @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 ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); + } + + /** Updates the reporting task with Markdown-formatted status text */ + /** @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 ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); + } + + /** Completes the reporting task with plain-text completion text */ + /** @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 ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); + } + + /** Completes the reporting task with Markdown-formatted completion text */ + /** @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 ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); + } + +} + +/** + * Thenable wrapper for ReportingTask that enables fluent chaining. + */ +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); + } + + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); + } + + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); + } + + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ServiceProvider +// ============================================================================ + +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); + } + + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); + } + + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); + } + + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); + } + + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); + } + + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); + } + + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); + } + + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); + } + + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); + } + + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); + } + + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); + } + + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); + } + +} + +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); + } + + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); + } + + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); + } + + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); + } + + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); + } + + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); + } + +} + +// ============================================================================ +// UserSecretsManager +// ============================================================================ + +/** + * Type class for UserSecretsManager. + */ +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); + } + + /** Saves state to user secrets from a JSON string */ + /** @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 UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + /** @internal */ + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting/getOrSetSecret', + rpcArgs + ); + return this; + } + + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); + } + +} + +/** + * Thenable wrapper for UserSecretsManager that enables fluent chaining. + */ +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); + } + +} + +// ============================================================================ +// AzureBicepResource +// ============================================================================ + +export class AzureBicepResource extends ResourceBuilderBase { + constructor(handle: AzureBicepResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureBicepResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureBicepResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureBicepResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise { + const helpLink = options?.helpLink; + return new AzureBicepResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureBicepResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureBicepResourcePromise { + const displayText = options?.displayText; + return new AzureBicepResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBicepResourcePromise { + const displayText = options?.displayText; + return new AzureBicepResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureBicepResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureBicepResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 AzureBicepResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureBicepResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureBicepResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureBicepResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzureBicepResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + 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 AzureBicepResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureBicepResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + 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 AzureBicepResource(result, this._client); + } + + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + } + + /** Determines whether a resource is marked as existing */ + 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, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBicepResource(result, this._client); + } + + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromise(this._runAsExistingInternal(name, resourceGroup)); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBicepResource(result, this._client); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBicepResource(result, this._client); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromise(this._asExistingInternal(name, resourceGroup)); + } + +} + +/** + * Thenable wrapper for AzureBicepResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureBicepResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureBicepResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); + } + + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); + } + +} + +// ============================================================================ +// AzureBlobStorageContainerResource +// ============================================================================ + +export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + constructor(handle: AzureBlobStorageContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageContainerResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureBlobStorageContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageContainerResourcePromise { + const helpLink = options?.helpLink; + return new AzureBlobStorageContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageContainerResourcePromise { + const displayText = options?.displayText; + return new AzureBlobStorageContainerResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageContainerResourcePromise { + const displayText = options?.displayText; + return new AzureBlobStorageContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageContainerResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureBlobStorageContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageContainerResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureBlobStorageContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageContainerResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureBlobStorageContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + +} + +/** + * Thenable wrapper for AzureBlobStorageContainerResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureBlobStorageContainerResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureBlobStorageContainerResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// AzureBlobStorageResource +// ============================================================================ + +export class AzureBlobStorageResource extends ResourceBuilderBase { + constructor(handle: AzureBlobStorageResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureBlobStorageResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureBlobStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureBlobStorageResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageResourcePromise { + const helpLink = options?.helpLink; + return new AzureBlobStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @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 AzureBlobStorageResource(result, this._client); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureBlobStorageResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageResourcePromise { + const displayText = options?.displayText; + return new AzureBlobStorageResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageResourcePromise { + const displayText = options?.displayText; + return new AzureBlobStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureBlobStorageResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureBlobStorageResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 AzureBlobStorageResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureBlobStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureBlobStorageResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureBlobStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzureBlobStorageResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureBlobStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureBlobStorageResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + +} + +/** + * Thenable wrapper for AzureBlobStorageResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureBlobStorageResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureBlobStorageResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// AzureDataLakeStorageFileSystemResource +// ============================================================================ + +export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase { + constructor(handle: AzureDataLakeStorageFileSystemResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageFileSystemResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureDataLakeStorageFileSystemResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { + const helpLink = options?.helpLink; + return new AzureDataLakeStorageFileSystemResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageFileSystemResourcePromise { + const displayText = options?.displayText; + return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageFileSystemResourcePromise { + const displayText = options?.displayText; + return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureDataLakeStorageFileSystemResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageFileSystemResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureDataLakeStorageFileSystemResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageFileSystemResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureDataLakeStorageFileSystemResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + +} + +/** + * Thenable wrapper for AzureDataLakeStorageFileSystemResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureDataLakeStorageFileSystemResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// AzureDataLakeStorageResource +// ============================================================================ + +export class AzureDataLakeStorageResource extends ResourceBuilderBase { + constructor(handle: AzureDataLakeStorageResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureDataLakeStorageResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureDataLakeStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageResourcePromise { + const helpLink = options?.helpLink; + return new AzureDataLakeStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @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 AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureDataLakeStorageResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageResourcePromise { + const displayText = options?.displayText; + return new AzureDataLakeStorageResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageResourcePromise { + const displayText = options?.displayText; + return new AzureDataLakeStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureDataLakeStorageResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureDataLakeStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureDataLakeStorageResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureDataLakeStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureDataLakeStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + +} + +/** + * Thenable wrapper for AzureDataLakeStorageResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureDataLakeStorageResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureDataLakeStorageResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// AzureEnvironmentResource +// ============================================================================ + +export class AzureEnvironmentResource extends ResourceBuilderBase { + constructor(handle: AzureEnvironmentResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureEnvironmentResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureEnvironmentResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureEnvironmentResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise { + const helpLink = options?.helpLink; + return new AzureEnvironmentResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureEnvironmentResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureEnvironmentResourcePromise { + const displayText = options?.displayText; + return new AzureEnvironmentResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureEnvironmentResourcePromise { + const displayText = options?.displayText; + return new AzureEnvironmentResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureEnvironmentResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureEnvironmentResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 AzureEnvironmentResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureEnvironmentResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureEnvironmentResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureEnvironmentResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzureEnvironmentResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + 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 AzureEnvironmentResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureEnvironmentResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** @internal */ + private async _withLocationInternal(location: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, location }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withLocation', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Sets the Azure location for the shared Azure environment resource */ + withLocation(location: ParameterResource): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withLocationInternal(location)); + } + + /** @internal */ + private async _withResourceGroupInternal(resourceGroup: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, resourceGroup }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withResourceGroup', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Sets the Azure resource group for the shared Azure environment resource */ + withResourceGroup(resourceGroup: ParameterResource): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withResourceGroupInternal(resourceGroup)); + } + +} + +/** + * Thenable wrapper for AzureEnvironmentResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureEnvironmentResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureEnvironmentResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + + /** Sets the Azure location for the shared Azure environment resource */ + withLocation(location: ParameterResource): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withLocation(location))); + } + + /** Sets the Azure resource group for the shared Azure environment resource */ + withResourceGroup(resourceGroup: ParameterResource): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withResourceGroup(resourceGroup))); + } + +} + +// ============================================================================ +// AzureNatGatewayResource +// ============================================================================ + +export class AzureNatGatewayResource extends ResourceBuilderBase { + constructor(handle: AzureNatGatewayResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureNatGatewayResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureNatGatewayResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureNatGatewayResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureNatGatewayResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureNatGatewayResourcePromise { + const helpLink = options?.helpLink; + return new AzureNatGatewayResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureNatGatewayResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureNatGatewayResourcePromise { + const displayText = options?.displayText; + return new AzureNatGatewayResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureNatGatewayResourcePromise { + const displayText = options?.displayText; + return new AzureNatGatewayResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureNatGatewayResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureNatGatewayResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 AzureNatGatewayResource(result, this._client); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureNatGatewayResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureNatGatewayResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureNatGatewayResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureNatGatewayResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureNatGatewayResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzureNatGatewayResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureNatGatewayResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureNatGatewayResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureNatGatewayResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureNatGatewayResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureNatGatewayResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureNatGatewayResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureNatGatewayResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withPublicIPAddressInternal(publicIPAddress: AzurePublicIPAddressResource): Promise { + const rpcArgs: Record = { builder: this._handle, publicIPAddress }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/withPublicIPAddress', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Associates an Azure Public IP Address resource with an Azure NAT Gateway resource. */ + withPublicIPAddress(publicIPAddress: AzurePublicIPAddressResource): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withPublicIPAddressInternal(publicIPAddress)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + + /** @internal */ + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureNatGatewayResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._configureInfrastructureInternal(configure)); + } + + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', + rpcArgs + ); + return new AzureNatGatewayResource(result, this._client); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + 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 AzureNatGatewayResource(result, this._client); + } + + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + } + + /** Determines whether a resource is marked as existing */ + 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, resourceGroup?: string | ParameterResource): Promise { + 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 AzureNatGatewayResource(result, this._client); + } + + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureNatGatewayResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureNatGatewayResourcePromise(this._runAsExistingInternal(name, resourceGroup)); + } + + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureNatGatewayResource(result, this._client); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureNatGatewayResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureNatGatewayResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureNatGatewayResource(result, this._client); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureNatGatewayResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureNatGatewayResourcePromise(this._asExistingInternal(name, resourceGroup)); + } + +} + +/** + * Thenable wrapper for AzureNatGatewayResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureNatGatewayResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureNatGatewayResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Associates an Azure Public IP Address resource with an Azure NAT Gateway resource. */ + withPublicIPAddress(publicIPAddress: AzurePublicIPAddressResource): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withPublicIPAddress(publicIPAddress))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); + } + + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureNatGatewayResourcePromise { + return new AzureNatGatewayResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); + } + +} + +// ============================================================================ +// AzureNetworkSecurityGroupResource +// ============================================================================ + +export class AzureNetworkSecurityGroupResource extends ResourceBuilderBase { + constructor(handle: AzureNetworkSecurityGroupResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureNetworkSecurityGroupResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureNetworkSecurityGroupResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + } + + /** @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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureNetworkSecurityGroupResourcePromise { + const helpLink = options?.helpLink; + return new AzureNetworkSecurityGroupResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureNetworkSecurityGroupResourcePromise { + const displayText = options?.displayText; + return new AzureNetworkSecurityGroupResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureNetworkSecurityGroupResourcePromise { + const displayText = options?.displayText; + return new AzureNetworkSecurityGroupResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withExplicitStartInternal()); + } + + /** @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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withHealthCheckInternal(key)); + } + + /** @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 ExecuteCommandContext(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 ProjectResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureNetworkSecurityGroupResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureNetworkSecurityGroupResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } - /** Adds a C# application resource */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); - return new ProjectResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } - /** Adds a C# application resource with configuration options */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureNetworkSecurityGroupResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureNetworkSecurityGroupResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', + 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 CSharpAppResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureNetworkSecurityGroupResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureNetworkSecurityGroupResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } - /** Adds an Azure SQL Database server resource */ /** @internal */ - async _addAzureSqlServerInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Sql/addAzureSqlServer', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addAzureSqlServer(name: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._addAzureSqlServerInternal(name)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } - /** Adds an Azure Storage resource */ /** @internal */ - async _addAzureStorageInternal(name: string): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withSecurityRuleInternal(rule: AzureSecurityRule): Promise { + const rpcArgs: Record = { builder: this._handle, rule }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/withSecurityRule', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a security rule to an Azure Network Security Group resource. */ + withSecurityRule(rule: AzureSecurityRule): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withSecurityRuleInternal(rule)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + async getOutput(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addAzureStorage', + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addAzureStorage(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._addAzureStorageInternal(name)); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterFromOutputInternal(name, value)); } - /** Adds an Azure Bicep template resource from a file */ /** @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', + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } - /** Adds an Azure Bicep template resource from inline Bicep content */ /** @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', + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._withParameterFromEndpointInternal(name, value)); } - /** Adds an Azure provisioning resource to the application model */ /** @internal */ - async _addAzureInfrastructureInternal(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): Promise { - const configureInfrastructureId = registerCallback(async (objData: unknown) => { + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; const obj = new AzureResourceInfrastructure(objHandle, this._client); - await configureInfrastructure(obj); + await configure(obj); }); - const rpcArgs: Record = { builder: this._handle, name, configureInfrastructure: configureInfrastructureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureInfrastructure', + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/configureInfrastructure', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._configureInfrastructureInternal(configure)); } - /** Adds Azure provisioning services to the distributed application builder */ /** @internal */ - async _addAzureProvisioningInternal(): Promise { + private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new DistributedApplicationBuilder(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); } - /** Adds the shared Azure environment resource to the application model */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { + private async _clearDefaultRoleAssignmentsInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + } + + /** Determines whether a resource is marked as existing */ + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); } - /** Adds an Azure user-assigned identity resource */ /** @internal */ - async _addAzureUserAssignedIdentityInternal(name: string): Promise { + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/runAsExisting', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureNetworkSecurityGroupResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureNetworkSecurityGroupResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } - /** Adds a SQL Server container resource */ /** @internal */ - async _addSqlServerInternal(name: string, password?: ParameterResource, port?: number): Promise { + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name }; - if (password !== undefined) rpcArgs.password = password; - if (port !== undefined) rpcArgs.port = port; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.SqlServer/addSqlServer', + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs ); - return new SqlServerServerResource(result, this._client); + return new AzureNetworkSecurityGroupResource(result, this._client); } - addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { - const password = options?.password; - const port = options?.port; - return new SqlServerServerResourcePromise(this._addSqlServerInternal(name, password, port)); + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureNetworkSecurityGroupResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureNetworkSecurityGroupResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + } + + /** @internal */ + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureNetworkSecurityGroupResource(result, this._client); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureNetworkSecurityGroupResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureNetworkSecurityGroupResourcePromise(this._asExistingInternal(name, resourceGroup)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for AzureNetworkSecurityGroupResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureNetworkSecurityGroupResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureNetworkSecurityGroupResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** Adds a connection string with a reference expression */ - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionString1(name, connectionStringExpression))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** Adds a container registry with string endpoint */ - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry1(name, endpoint, options))); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** Adds an external service with a URI */ - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService2(name, uri))); + /** Adds a health check by key */ + withHealthCheck(key: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } - /** Adds an external service with a parameter URL */ - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService1(name, urlParameter))); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } - /** Adds a parameter with a default value */ - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter1(name, value, options))); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } - /** Adds an Azure SQL Database server resource */ - addAzureSqlServer(name: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.addAzureSqlServer(name))); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); } - /** Adds an Azure Storage resource */ - addAzureStorage(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.addAzureStorage(name))); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + /** Adds a security rule to an Azure Network Security Group resource. */ + withSecurityRule(rule: AzureSecurityRule): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withSecurityRule(rule))); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); } - /** Adds a SQL Server container resource */ - addSqlServer(name: string, options?: AddSqlServerOptions): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.addSqlServer(name, options))); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameter(name))); } -} + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } -// ============================================================================ -// DistributedApplicationEventing -// ============================================================================ + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } -/** - * Type class for DistributedApplicationEventing. - */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } - /** Invokes the Unsubscribe method */ - /** @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; + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); } -} + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } -/** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. - */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); + } - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureNetworkSecurityGroupResourcePromise { + return new AzureNetworkSecurityGroupResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } // ============================================================================ -// AzureBicepResource +// AzurePrivateEndpointResource // ============================================================================ -export class AzureBicepResource extends ResourceBuilderBase { - constructor(handle: AzureBicepResourceHandle, client: AspireClientRpc) { +export class AzurePrivateEndpointResource extends ResourceBuilderBase { + constructor(handle: AzurePrivateEndpointResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise { + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePrivateEndpointResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new AzureBicepResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new AzurePrivateEndpointResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise { + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePrivateEndpointResourcePromise { const helpLink = options?.helpLink; - return new AzureBicepResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + return new AzurePrivateEndpointResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureBicepResourcePromise { + withUrl(url: string, options?: WithUrlOptions): AzurePrivateEndpointResourcePromise { const displayText = options?.displayText; - return new AzureBicepResourcePromise(this._withUrlInternal(url, displayText)); + return new AzurePrivateEndpointResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBicepResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzurePrivateEndpointResourcePromise { const displayText = options?.displayText; - return new AzureBicepResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new AzurePrivateEndpointResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { + private async _excludeFromManifestInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._excludeFromManifestInternal()); + excludeFromManifest(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { + private async _withHealthCheckInternal(key: string): Promise { const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withHealthCheckInternal(key)); + withHealthCheck(key: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + 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 ExecuteCommandContext(argHandle, this._client); @@ -2595,216 +11336,430 @@ export class AzureBicepResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withCommand', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePrivateEndpointResourcePromise { const commandOptions = options?.commandOptions; - return new AzureBicepResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new AzurePrivateEndpointResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzurePrivateEndpointResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzurePrivateEndpointResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzurePrivateEndpointResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzurePrivateEndpointResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzurePrivateEndpointResourcePromise { + const iconVariant = options?.iconVariant; + return new AzurePrivateEndpointResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzurePrivateEndpointResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 PipelineStepContext(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 AzurePrivateEndpointResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePrivateEndpointResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzurePrivateEndpointResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzurePrivateEndpointResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzurePrivateEndpointResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzurePrivateEndpointResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzurePrivateEndpointResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzurePrivateEndpointResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzurePrivateEndpointResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withParentRelationshipInternal(parent)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } - /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + /** Gets an output reference from an Azure Bicep template resource */ + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', rpcArgs ); - return new AzureBicepResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withChildRelationshipInternal(child)); } /** @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', + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureBicepResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterInternal(name)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._excludeFromMcpInternal()); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterStringValueInternal(name, value)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterStringValuesInternal(name, value)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterFromParameterInternal(name, value)); } /** @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 PipelineStepContext(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', + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 AzureBicepResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterFromOutputInternal(name, value)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); + return new AzurePrivateEndpointResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._withParameterFromEndpointInternal(name, value)); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._configureInfrastructureInternal(configure)); } /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { + private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsConnectionStringInternal()); + publishAsConnectionString(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._publishAsConnectionStringInternal()); } /** Gets the normalized Bicep identifier for an Azure resource */ @@ -2817,18 +11772,18 @@ export class AzureBicepResource extends ResourceBuilderBase { + private async _clearDefaultRoleAssignmentsInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + clearDefaultRoleAssignments(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._clearDefaultRoleAssignmentsInternal()); } /** Determines whether a resource is marked as existing */ @@ -2841,215 +11796,256 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingInternal(name, resourceGroup)); - } - - /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzurePrivateEndpointResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzurePrivateEndpointResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzurePrivateEndpointResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzurePrivateEndpointResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBicepResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzurePrivateEndpointResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzurePrivateEndpointResourcePromise(this._asExistingInternal(name, resourceGroup)); } } /** - * Thenable wrapper for AzureBicepResource that enables fluent chaining. + * Thenable wrapper for AzurePrivateEndpointResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureBicepResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzurePrivateEndpointResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureBicepResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzurePrivateEndpointResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + excludeFromMcp(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); } /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + publishAsConnectionString(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); } /** Gets the normalized Bicep identifier for an Azure resource */ @@ -3058,8 +12054,8 @@ export class AzureBicepResourcePromise implements PromiseLike obj.clearDefaultRoleAssignments())); + clearDefaultRoleAssignments(): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); } /** Determines whether a resource is marked as existing */ @@ -3067,263 +12063,223 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } // ============================================================================ -// AzureBlobStorageContainerResource +// AzureProvisioningResource // ============================================================================ -export class AzureBlobStorageContainerResource extends ResourceBuilderBase { - constructor(handle: AzureBlobStorageContainerResourceHandle, client: AspireClientRpc) { +export class AzureProvisioningResource extends ResourceBuilderBase { + constructor(handle: AzureProvisioningResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageContainerResourcePromise { + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new AzureBlobStorageContainerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new AzureProvisioningResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageContainerResourcePromise { + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise { const helpLink = options?.helpLink; - return new AzureBlobStorageContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', - rpcArgs - ); - return new AzureBlobStorageContainerResource(result, this._client); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withConnectionPropertyInternal(name, value)); - } - - /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', - rpcArgs - ); - return new AzureBlobStorageContainerResource(result, this._client); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + return new AzureProvisioningResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageContainerResourcePromise { + withUrl(url: string, options?: WithUrlOptions): AzureProvisioningResourcePromise { const displayText = options?.displayText; - return new AzureBlobStorageContainerResourcePromise(this._withUrlInternal(url, displayText)); + return new AzureProvisioningResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageContainerResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureProvisioningResourcePromise { const displayText = options?.displayText; - return new AzureBlobStorageContainerResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new AzureProvisioningResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { + private async _excludeFromManifestInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._excludeFromManifestInternal()); + excludeFromManifest(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { + private async _withHealthCheckInternal(key: string): Promise { const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withHealthCheckInternal(key)); + withHealthCheck(key: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + 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 ExecuteCommandContext(argHandle, this._client); @@ -3331,113 +12287,98 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withCommand', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageContainerResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise { const commandOptions = options?.commandOptions; - return new AzureBlobStorageContainerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new AzureProvisioningResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withIconName', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageContainerResourcePromise { + withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise { const iconVariant = options?.iconVariant; - return new AzureBlobStorageContainerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + return new AzureProvisioningResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new AzureBlobStorageContainerResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._excludeFromMcpInternal()); - } - - /** @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 AzureBlobStorageContainerResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + 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 PipelineStepContext(argHandle, this._client); @@ -3448,60 +12389,60 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageContainerResourcePromise { + 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 AzureBlobStorageContainerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + return new AzureProvisioningResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; const arg = new PipelineConfigurationContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -3514,1306 +12455,1414 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBlobStorageContainerResource(result, this._client); - } - - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); - } - -} - -/** - * Thenable wrapper for AzureBlobStorageContainerResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class AzureBlobStorageContainerResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: AzureBlobStorageContainerResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + return new AzureProvisioningResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureProvisioningResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** Gets an output reference from an Azure Bicep template resource */ + async getOutput(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterInternal(name)); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterStringValueInternal(name, value)); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterStringValuesInternal(name, value)); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterFromParameterInternal(name, value)); } -} - -// ============================================================================ -// AzureBlobStorageResource -// ============================================================================ + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } -export class AzureBlobStorageResource extends ResourceBuilderBase { - constructor(handle: AzureBlobStorageResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); - return new AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withContainerRegistryInternal(registry)); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterFromOutputInternal(name, value)); } /** @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', + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureBlobStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } /** @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', + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); - return new AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageResourcePromise { - const helpLink = options?.helpLink; - return new AzureBlobStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withParameterFromEndpointInternal(name, value)); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); } /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + } + + /** Determines whether a resource is marked as existing */ + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _withUrlInternal(url: string, 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', + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageResourcePromise { - const displayText = options?.displayText; - return new AzureBlobStorageResourcePromise(this._withUrlInternal(url, displayText)); + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureBlobStorageResource(result, this._client); + return new AzureProvisioningResource(result, this._client); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromise(this._asExistingInternal(name, resourceGroup)); + } + +} + +/** + * Thenable wrapper for AzureProvisioningResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureProvisioningResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureProvisioningResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + } + + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageResourcePromise { - const displayText = options?.displayText; - return new AzureBlobStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** @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 AzureBlobStorageResource(result, this._client); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._excludeFromManifestInternal()); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withExplicitStartInternal()); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** @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 AzureBlobStorageResource(result, this._client); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withHealthCheckInternal(key)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } - /** @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 ExecuteCommandContext(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 AzureBlobStorageResource(result, this._client); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureBlobStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } - /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withParentRelationshipInternal(parent)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withChildRelationshipInternal(child)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** @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 AzureBlobStorageResource(result, this._client); + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureBlobStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameter(name))); } - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._excludeFromMcpInternal()); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); } - /** @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 AzureBlobStorageResource(result, this._client); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } - /** @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 AzureBlobStorageResource(result, this._client); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); } - /** @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 PipelineStepContext(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 AzureBlobStorageResource(result, this._client); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureBlobStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); } - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); } - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(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 AzureBlobStorageResource(result, this._client); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } - /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', - rpcArgs - ); - return new AzureBlobStorageResource(result, this._client); + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } -/** - * Thenable wrapper for AzureBlobStorageResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class AzureBlobStorageResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +// ============================================================================ +// AzurePublicIPAddressResource +// ============================================================================ - then( - onfulfilled?: ((value: AzureBlobStorageResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); +export class AzurePublicIPAddressResource extends ResourceBuilderBase { + constructor(handle: AzurePublicIPAddressResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 AzurePublicIPAddressResource(result, this._client); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePublicIPAddressResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzurePublicIPAddressResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** @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 AzurePublicIPAddressResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePublicIPAddressResourcePromise { + const helpLink = options?.helpLink; + return new AzurePublicIPAddressResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withUrlsCallbackInternal(callback)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @internal */ + private async _withUrlInternal(url: string, 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 AzurePublicIPAddressResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzurePublicIPAddressResourcePromise { + const displayText = options?.displayText; + return new AzurePublicIPAddressResourcePromise(this._withUrlInternal(url, displayText)); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzurePublicIPAddressResourcePromise { + const displayText = options?.displayText; + return new AzurePublicIPAddressResourcePromise(this._withUrlExpressionInternal(url, displayText)); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @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 AzurePublicIPAddressResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._excludeFromManifestInternal()); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** Prevents resource from starting automatically */ + withExplicitStart(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withExplicitStartInternal()); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** @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 AzurePublicIPAddressResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Adds a health check by key */ + withHealthCheck(key: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withHealthCheckInternal(key)); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** @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 ExecuteCommandContext(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 AzurePublicIPAddressResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePublicIPAddressResourcePromise { + const commandOptions = options?.commandOptions; + return new AzurePublicIPAddressResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzurePublicIPAddressResource(result, this._client); } -} - -// ============================================================================ -// AzureDataLakeStorageFileSystemResource -// ============================================================================ - -export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase { - constructor(handle: AzureDataLakeStorageFileSystemResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withContainerRegistryInternal(registry)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withChildRelationshipInternal(child)); } /** @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', + 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 AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageFileSystemResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureDataLakeStorageFileSystemResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzurePublicIPAddressResourcePromise { + const iconVariant = options?.iconVariant; + return new AzurePublicIPAddressResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @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', + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { - const helpLink = options?.helpLink; - return new AzureDataLakeStorageFileSystemResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', + 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 PipelineStepContext(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 AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePublicIPAddressResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzurePublicIPAddressResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, 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', + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageFileSystemResourcePromise { - const displayText = options?.displayText; - return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlInternal(url, displayText)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageFileSystemResourcePromise { - const displayText = options?.displayText; - return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._onInitializeResourceInternal(callback)); } /** @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); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpoint', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceReady', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._excludeFromManifestInternal()); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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 _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withExplicitStartInternal()); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterInternal(name)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withHealthCheckInternal(key)); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterStringValueInternal(name, value)); } /** @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 ExecuteCommandContext(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', + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureDataLakeStorageFileSystemResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterStringValuesInternal(name, value)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withParentRelationshipInternal(parent)); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterFromParameterInternal(name, value)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); } /** @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', + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageFileSystemResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureDataLakeStorageFileSystemResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterFromOutputInternal(name, value)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._excludeFromMcpInternal()); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._withParameterFromEndpointInternal(name, value)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._configureInfrastructureInternal(configure)); } /** @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 PipelineStepContext(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', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._publishAsConnectionStringInternal()); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageFileSystemResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureDataLakeStorageFileSystemResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Gets the normalized Bicep identifier for an Azure resource */ + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + } + + /** Determines whether a resource is marked as existing */ + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', + rpcArgs + ); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzurePublicIPAddressResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzurePublicIPAddressResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzurePublicIPAddressResource(result, this._client); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzurePublicIPAddressResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzurePublicIPAddressResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzurePublicIPAddressResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzurePublicIPAddressResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzurePublicIPAddressResourcePromise(this._asExistingInternal(name, resourceGroup)); } } /** - * Thenable wrapper for AzureDataLakeStorageFileSystemResource that enables fluent chaining. + * Thenable wrapper for AzurePublicIPAddressResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzurePublicIPAddressResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureDataLakeStorageFileSystemResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzurePublicIPAddressResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -4821,243 +13870,357 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); + } + + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzurePublicIPAddressResourcePromise { + return new AzurePublicIPAddressResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } // ============================================================================ -// AzureDataLakeStorageResource +// AzureQueueStorageQueueResource // ============================================================================ -export class AzureDataLakeStorageResource extends ResourceBuilderBase { - constructor(handle: AzureDataLakeStorageResourceHandle, client: AspireClientRpc) { +export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + constructor(handle: AzureQueueStorageQueueResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageResourcePromise { + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageQueueResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new AzureDataLakeStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new AzureQueueStorageQueueResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageResourcePromise { + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageQueueResourcePromise { const helpLink = options?.helpLink; - return new AzureDataLakeStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + return new AzureQueueStorageQueueResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withConnectionPropertyInternal(name, value)); } /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionPropertyValue', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + withConnectionPropertyValue(name: string, value: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageResourcePromise { + withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageQueueResourcePromise { const displayText = options?.displayText; - return new AzureDataLakeStorageResourcePromise(this._withUrlInternal(url, displayText)); + return new AzureQueueStorageQueueResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageQueueResourcePromise { const displayText = options?.displayText; - return new AzureDataLakeStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new AzureQueueStorageQueueResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { + private async _excludeFromManifestInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._excludeFromManifestInternal()); + excludeFromManifest(): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { + private async _withHealthCheckInternal(key: string): Promise { const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withHealthCheckInternal(key)); + withHealthCheck(key: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + 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 ExecuteCommandContext(argHandle, this._client); @@ -5065,113 +14228,98 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withCommand', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageQueueResourcePromise { const commandOptions = options?.commandOptions; - return new AzureDataLakeStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new AzureQueueStorageQueueResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withIconName', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageResourcePromise { + withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageQueueResourcePromise { const iconVariant = options?.iconVariant; - return new AzureDataLakeStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + return new AzureQueueStorageQueueResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._excludeFromMcpInternal()); - } - - /** @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 AzureDataLakeStorageResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureDataLakeStorageResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + excludeFromMcp(): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + 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 PipelineStepContext(argHandle, this._client); @@ -5182,60 +14330,60 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageQueueResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new AzureDataLakeStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + return new AzureQueueStorageQueueResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; const arg = new PipelineConfigurationContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -5248,150 +14396,250 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } } /** - * Thenable wrapper for AzureDataLakeStorageResource that enables fluent chaining. + * Thenable wrapper for AzureQueueStorageQueueResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureDataLakeStorageResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureQueueStorageQueueResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureDataLakeStorageResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureQueueStorageQueueResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + withConnectionPropertyValue(name: string, value: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -5399,213 +14647,277 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } } // ============================================================================ -// AzureEnvironmentResource +// AzureQueueStorageResource // ============================================================================ -export class AzureEnvironmentResource extends ResourceBuilderBase { - constructor(handle: AzureEnvironmentResourceHandle, client: AspireClientRpc) { +export class AzureQueueStorageResource extends ResourceBuilderBase { + constructor(handle: AzureQueueStorageResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise { + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new AzureEnvironmentResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new AzureQueueStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise { + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageResourcePromise { const helpLink = options?.helpLink; - return new AzureEnvironmentResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + return new AzureQueueStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + 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 AzureQueueStorageResource(result, this._client); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); + } + + /** @internal */ + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureEnvironmentResourcePromise { + withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageResourcePromise { const displayText = options?.displayText; - return new AzureEnvironmentResourcePromise(this._withUrlInternal(url, displayText)); + return new AzureQueueStorageResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureEnvironmentResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageResourcePromise { const displayText = options?.displayText; - return new AzureEnvironmentResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new AzureQueueStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { + private async _excludeFromManifestInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._excludeFromManifestInternal()); + excludeFromManifest(): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { + private async _withHealthCheckInternal(key: string): Promise { const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withHealthCheckInternal(key)); + withHealthCheck(key: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + 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 ExecuteCommandContext(argHandle, this._client); @@ -5613,113 +14925,98 @@ export class AzureEnvironmentResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withCommand', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageResourcePromise { const commandOptions = options?.commandOptions; - return new AzureEnvironmentResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new AzureQueueStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withIconName', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise { + withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageResourcePromise { const iconVariant = options?.iconVariant; - return new AzureEnvironmentResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + return new AzureQueueStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._excludeFromMcpInternal()); - } - - /** @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 AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + excludeFromMcp(): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + 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 PipelineStepContext(argHandle, this._client); @@ -5730,60 +15027,60 @@ export class AzureEnvironmentResource extends ResourceBuilderBase( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new AzureEnvironmentResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + return new AzureQueueStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; const arg = new PipelineConfigurationContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -5796,170 +15093,250 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withLocationInternal(location: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, location }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withLocation', + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } - /** Sets the Azure location for the shared Azure environment resource */ - withLocation(location: ParameterResource): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withLocationInternal(location)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withResourceGroupInternal(resourceGroup: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withResourceGroup', + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureEnvironmentResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } - /** Sets the Azure resource group for the shared Azure environment resource */ - withResourceGroup(resourceGroup: ParameterResource): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withResourceGroupInternal(resourceGroup)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } } /** - * Thenable wrapper for AzureEnvironmentResource that enables fluent chaining. + * Thenable wrapper for AzureQueueStorageResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureEnvironmentResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureQueueStorageResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureEnvironmentResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureQueueStorageResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -5967,799 +15344,782 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); - } - - /** Sets the Azure location for the shared Azure environment resource */ - withLocation(location: ParameterResource): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withLocation(location))); - } - - /** Sets the Azure resource group for the shared Azure environment resource */ - withResourceGroup(resourceGroup: ParameterResource): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withResourceGroup(resourceGroup))); - } - -} - -// ============================================================================ -// AzureProvisioningResource -// ============================================================================ - -export class AzureProvisioningResource extends ResourceBuilderBase { - constructor(handle: AzureProvisioningResourceHandle, client: AspireClientRpc) { - super(handle, client); - } - - /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withContainerRegistryInternal(registry)); - } - - /** @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 AzureProvisioningResource(result, this._client); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureProvisioningResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); - } - - /** @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 AzureProvisioningResource(result, this._client); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise { - const helpLink = options?.helpLink; - return new AzureProvisioningResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** @internal */ - private async _withUrlInternal(url: string, 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 AzureProvisioningResource(result, this._client); - } +} - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureProvisioningResourcePromise { - const displayText = options?.displayText; - return new AzureProvisioningResourcePromise(this._withUrlInternal(url, displayText)); - } +// ============================================================================ +// AzureSqlDatabaseResource +// ============================================================================ - /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); +export class AzureSqlDatabaseResource extends ResourceBuilderBase { + constructor(handle: AzureSqlDatabaseResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureProvisioningResourcePromise { - const displayText = options?.displayText; - return new AzureProvisioningResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } + /** Gets the Parent property */ + parent = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.parent', + { context: this._handle } + ); + return new AzureSqlServerResource(handle, 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 AzureProvisioningResource(result, this._client); - } + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } + /** Gets the DatabaseName property */ + databaseName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.databaseName', + { context: this._handle } + ); + }, + }; - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } + /** Gets the IsContainer property */ + isContainer = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.isContainer', + { context: this._handle } + ); + }, + }; - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._excludeFromManifestInternal()); - } + /** Gets the UriExpression property */ + uriExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.uriExpression', + { context: this._handle } + ); + }, + }; - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } + /** Gets the JdbcConnectionString property */ + jdbcConnectionString = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.jdbcConnectionString', + { context: this._handle } + ); + }, + }; - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withExplicitStartInternal()); - } + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.name', + { context: this._handle } + ); + }, + }; /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withHealthCheckInternal(key)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withContainerRegistryInternal(registry)); } /** @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 ExecuteCommandContext(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', + 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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureProvisioningResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlDatabaseResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureSqlDatabaseResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParentRelationshipInternal(parent)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlDatabaseResourcePromise { + const helpLink = options?.helpLink; + return new AzureSqlDatabaseResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withConnectionPropertyInternal(name, value)); } /** @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', + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureProvisioningResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withConnectionPropertyValueInternal(name, value)); } - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', rpcArgs ); - return new AzureProvisioningResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @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 PipelineStepContext(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', + private async _withUrlInternal(url: string, 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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 AzureProvisioningResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureSqlDatabaseResourcePromise { + const displayText = options?.displayText; + return new AzureSqlDatabaseResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + private async _withUrlExpressionInternal(url: 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/withUrlExpression', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlDatabaseResourcePromise { + const displayText = options?.displayText; + return new AzureSqlDatabaseResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); + const obj = wrapIfHandle(objData) as ResourceUrlAnnotation; await callback(obj); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', rpcArgs ); + return new AzureSqlDatabaseResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withExplicitStartInternal()); } - /** Gets an output reference from an Azure Bicep template resource */ - async getOutput(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/getOutput', + /** @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 AzureSqlDatabaseResource(result, this._client); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withParameterInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameter', + 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 ExecuteCommandContext(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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter without a value */ - withParameter(name: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterInternal(name)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlDatabaseResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureSqlDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParameterStringValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterStringValue', + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterStringValueInternal(name, value)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ - private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterStringValues', + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterStringValuesInternal(name, value)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromParameter', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterFromParameterInternal(name, value)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromConnectionString', + 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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlDatabaseResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureSqlDatabaseResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromOutput', + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterFromOutputInternal(name, value)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + 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 PipelineStepContext(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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlDatabaseResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureSqlDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromEndpoint', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withParameterFromEndpointInternal(name, value)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsConnectionString', + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsConnectionStringInternal()); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); } - /** Gets the normalized Bicep identifier for an Azure resource */ - async getBicepIdentifier(): Promise { + /** Gets the resource name */ + async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/getBicepIdentifier', + 'Aspire.Hosting/getResourceName', rpcArgs ); } /** @internal */ - private async _clearDefaultRoleAssignmentsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); - } - - /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + return new AzureSqlDatabaseResource(result, this._client); } - /** Determines whether a resource is marked as existing */ - async isExisting(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/isExisting', + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureSqlDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExisting', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingInternal(name, resourceGroup)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExisting', + private async _withDefaultAzureSkuInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Sql/withDefaultAzureSku', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + /** Configures the Azure SQL database to use the default Azure SKU */ + withDefaultAzureSku(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withDefaultAzureSkuInternal()); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExisting', + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } } /** - * Thenable wrapper for AzureProvisioningResource that enables fluent chaining. + * Thenable wrapper for AzureSqlDatabaseResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureProvisioningResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureSqlDatabaseResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureProvisioningResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureSqlDatabaseResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + } + + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + } + + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -6767,333 +16127,455 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } - /** Gets an output reference from an Azure Bicep template resource */ - getOutput(name: string): Promise { - return this._promise.then(obj => obj.getOutput(name)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } - /** Adds a Bicep parameter without a value */ - withParameter(name: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameter(name))); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } - /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + /** Configures the Azure SQL database to use the default Azure SKU */ + withDefaultAzureSku(): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withDefaultAzureSku())); } - /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); - } +} - /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); - } +// ============================================================================ +// AzureSqlServerResource +// ============================================================================ - /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); +export class AzureSqlServerResource extends ResourceBuilderBase { + constructor(handle: AzureSqlServerResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); - } + /** Gets the FullyQualifiedDomainName property */ + fullyQualifiedDomainName = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.fullyQualifiedDomainName', + { context: this._handle } + ); + return new BicepOutputReference(handle, this._client); + }, + }; + + /** Gets the NameOutputReference property */ + nameOutputReference = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.nameOutputReference', + { context: this._handle } + ); + return new BicepOutputReference(handle, this._client); + }, + }; + + /** Gets the Id property */ + id = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.id', + { context: this._handle } + ); + return new BicepOutputReference(handle, this._client); + }, + }; + + /** Gets the HostName property */ + hostName = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.hostName', + { context: this._handle } + ); + }, + }; + + /** Gets the Port property */ + port = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.port', + { context: this._handle } + ); + }, + }; + + /** Gets the UriExpression property */ + uriExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.uriExpression', + { context: this._handle } + ); + }, + }; - /** Gets the normalized Bicep identifier for an Azure resource */ - getBicepIdentifier(): Promise { - return this._promise.then(obj => obj.getBicepIdentifier()); - } + /** Gets the ConnectionStringExpression property */ + connectionStringExpression = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.connectionStringExpression', + { context: this._handle } + ); + }, + }; - /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); - } + /** Gets the IsContainer property */ + isContainer = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.isContainer', + { context: this._handle } + ); + }, + }; - /** Determines whether a resource is marked as existing */ - isExisting(): Promise { - return this._promise.then(obj => obj.isExisting()); + /** Gets the AzureSqlDatabases property */ + private _azureSqlDatabases?: AspireDict; + get azureSqlDatabases(): AspireDict { + if (!this._azureSqlDatabases) { + this._azureSqlDatabases = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureSqlServerResource.azureSqlDatabases', + 'Aspire.Hosting.Azure/AzureSqlServerResource.azureSqlDatabases' + ); + } + return this._azureSqlDatabases; } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); + /** Gets the Databases property */ + private _databases?: AspireDict; + get databases(): AspireDict { + if (!this._databases) { + this._databases = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureSqlServerResource.databases', + 'Aspire.Hosting.Azure/AzureSqlServerResource.databases' + ); + } + return this._databases; } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } + /** Gets the JdbcConnectionString property */ + jdbcConnectionString = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.jdbcConnectionString', + { context: this._handle } + ); + }, + }; - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + /** Gets the Parameters property */ + private _parameters?: AspireDict; + get parameters(): AspireDict { + if (!this._parameters) { + this._parameters = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureSqlServerResource.parameters', + 'Aspire.Hosting.Azure/AzureSqlServerResource.parameters' + ); + } + return this._parameters; } - /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + /** Gets the Outputs property */ + private _outputs?: AspireDict; + get outputs(): AspireDict { + if (!this._outputs) { + this._outputs = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureSqlServerResource.outputs', + 'Aspire.Hosting.Azure/AzureSqlServerResource.outputs' + ); + } + return this._outputs; } - /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Gets the SecretOutputs property */ + private _secretOutputs?: AspireDict; + get secretOutputs(): AspireDict { + if (!this._secretOutputs) { + this._secretOutputs = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Azure/AzureSqlServerResource.secretOutputs', + 'Aspire.Hosting.Azure/AzureSqlServerResource.secretOutputs' + ); + } + return this._secretOutputs; } -} - -// ============================================================================ -// AzureQueueStorageQueueResource -// ============================================================================ - -export class AzureQueueStorageQueueResource extends ResourceBuilderBase { - constructor(handle: AzureQueueStorageQueueResourceHandle, client: AspireClientRpc) { - super(handle, client); - } + /** Gets the Name property */ + name = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/AzureSqlServerResource.name', + { context: this._handle } + ); + }, + }; /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageQueueResourcePromise { + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlServerResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new AzureQueueStorageQueueResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new AzureSqlServerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageQueueResourcePromise { + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlServerResourcePromise { const helpLink = options?.helpLink; - return new AzureQueueStorageQueueResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + return new AzureSqlServerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + private async _withConnectionPropertyInternal(name: string, value: string | ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionProperty', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withConnectionPropertyInternal(name, value)); } /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withConnectionPropertyValue', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + withConnectionPropertyValue(name: string, value: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageQueueResourcePromise { + withUrl(url: string, options?: WithUrlOptions): AzureSqlServerResourcePromise { const displayText = options?.displayText; - return new AzureQueueStorageQueueResourcePromise(this._withUrlInternal(url, displayText)); + return new AzureSqlServerResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageQueueResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlServerResourcePromise { const displayText = options?.displayText; - return new AzureQueueStorageQueueResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new AzureSqlServerResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { + private async _excludeFromManifestInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._excludeFromManifestInternal()); + excludeFromManifest(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { + private async _withHealthCheckInternal(key: string): Promise { const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withHealthCheckInternal(key)); + withHealthCheck(key: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + 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 ExecuteCommandContext(argHandle, this._client); @@ -7101,113 +16583,98 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withCommand', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageQueueResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlServerResourcePromise { const commandOptions = options?.commandOptions; - return new AzureQueueStorageQueueResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new AzureSqlServerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureSqlServerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withIconName', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageQueueResourcePromise { + withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlServerResourcePromise { const iconVariant = options?.iconVariant; - return new AzureQueueStorageQueueResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + return new AzureSqlServerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._excludeFromMcpInternal()); - } - - /** @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 AzureQueueStorageQueueResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureQueueStorageQueueResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + excludeFromMcp(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + 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 PipelineStepContext(argHandle, this._client); @@ -7218,794 +16685,633 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageQueueResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlServerResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new AzureQueueStorageQueueResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + return new AzureSqlServerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; const arg = new PipelineConfigurationContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureQueueStorageQueueResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfiguration', rpcArgs - ); - return new AzureQueueStorageQueueResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', - rpcArgs - ); - return new AzureQueueStorageQueueResource(result, this._client); - } - - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); - } - -} - -/** - * Thenable wrapper for AzureQueueStorageQueueResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class AzureQueueStorageQueueResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: AzureQueueStorageQueueResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); - } - - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); - } - - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); - } - - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); - } - - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); - } - - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withExplicitStart())); - } - - /** Adds a health check by key */ - withHealthCheck(key: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); - } - - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); - } - - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + ); + return new AzureSqlServerResource(result, this._client); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureSqlServerResource(result, this._client); } -} - -// ============================================================================ -// AzureQueueStorageResource -// ============================================================================ - -export class AzureQueueStorageResource extends ResourceBuilderBase { - constructor(handle: AzureQueueStorageResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withContainerRegistryInternal(registry)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._onResourceStoppedInternal(callback)); } /** @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', + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureQueueStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @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', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageResourcePromise { - const helpLink = options?.helpLink; - return new AzureQueueStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', + 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.Sql/addDatabase', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlDatabaseResource(result, this._client); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + /** Adds an Azure SQL database resource */ + addDatabase(name: string, options?: AddDatabaseOptions): AzureSqlDatabaseResourcePromise { + const databaseName = options?.databaseName; + return new AzureSqlDatabaseResourcePromise(this._addDatabaseInternal(name, databaseName)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + private async _runAsContainerInternal(configureContainer?: (obj: SqlServerServerResource) => Promise): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as SqlServerServerResourceHandle; + const obj = new SqlServerServerResource(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.Sql/runAsContainer', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Configures the Azure SQL server to run locally in a SQL Server container */ + runAsContainer(options?: RunAsContainerOptions): AzureSqlServerResourcePromise { + const configureContainer = options?.configureContainer; + return new AzureSqlServerResourcePromise(this._runAsContainerInternal(configureContainer)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + private async _withAdminDeploymentScriptSubnetInternal(subnet: AzureSubnetResource): Promise { + const rpcArgs: Record = { builder: this._handle, subnet }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Sql/withAdminDeploymentScriptSubnet', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Configures the Azure SQL server to use a specific subnet for deployment scripts */ + withAdminDeploymentScriptSubnet(subnet: AzureSubnetResource): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withAdminDeploymentScriptSubnetInternal(subnet)); } /** @internal */ - private async _withUrlInternal(url: string, 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', + private async _withAdminDeploymentScriptStorageInternal(storage: AzureStorageResource): Promise { + const rpcArgs: Record = { builder: this._handle, storage }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Sql/withAdminDeploymentScriptStorage', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageResourcePromise { - const displayText = options?.displayText; - return new AzureQueueStorageResourcePromise(this._withUrlInternal(url, displayText)); + /** Configures the Azure SQL server to use a specific storage account for deployment scripts */ + withAdminDeploymentScriptStorage(storage: AzureStorageResource): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withAdminDeploymentScriptStorageInternal(storage)); } /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageResourcePromise { - const displayText = options?.displayText; - return new AzureQueueStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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 _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', + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterInternal(name)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._excludeFromManifestInternal()); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterStringValueInternal(name, value)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withExplicitStartInternal()); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterStringValuesInternal(name, value)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withHealthCheckInternal(key)); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterFromParameterInternal(name, value)); } /** @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 ExecuteCommandContext(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', + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureQueueStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withParentRelationshipInternal(parent)); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterFromOutputInternal(name, value)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } /** @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', + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureQueueStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._withParameterFromEndpointInternal(name, value)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._excludeFromMcpInternal()); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._configureInfrastructureInternal(configure)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._publishAsConnectionStringInternal()); } - /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + /** Gets the normalized Bicep identifier for an Azure resource */ + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @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 PipelineStepContext(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', + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureQueueStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._clearDefaultRoleAssignmentsInternal()); } - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + /** Determines whether a resource is marked as existing */ + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureSqlServerResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureSqlServerResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureSqlServerResource(result, this._client); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureSqlServerResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureSqlServerResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureQueueStorageResource(result, this._client); + return new AzureSqlServerResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureSqlServerResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureSqlServerResourcePromise(this._asExistingInternal(name, resourceGroup)); } } /** - * Thenable wrapper for AzureQueueStorageResource that enables fluent chaining. + * Thenable wrapper for AzureSqlServerResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureQueueStorageResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureSqlServerResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureQueueStorageResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureSqlServerResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + withConnectionPropertyValue(name: string, value: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + } + + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -8013,2460 +17319,2259 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.getResourceName()); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } -} + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } -// ============================================================================ -// AzureSqlDatabaseResource -// ============================================================================ + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } -export class AzureSqlDatabaseResource extends ResourceBuilderBase { - constructor(handle: AzureSqlDatabaseResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** Gets the Parent property */ - parent = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.parent', - { context: this._handle } - ); - return new AzureSqlServerResource(handle, this._client); - }, - }; + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } - /** Gets the ConnectionStringExpression property */ - connectionStringExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.connectionStringExpression', - { context: this._handle } - ); - }, - }; + /** Adds an Azure SQL database resource */ + addDatabase(name: string, options?: AddDatabaseOptions): AzureSqlDatabaseResourcePromise { + return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.addDatabase(name, options))); + } - /** Gets the DatabaseName property */ - databaseName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.databaseName', - { context: this._handle } - ); - }, - }; + /** Configures the Azure SQL server to run locally in a SQL Server container */ + runAsContainer(options?: RunAsContainerOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.runAsContainer(options))); + } - /** Gets the IsContainer property */ - isContainer = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.isContainer', - { context: this._handle } - ); - }, - }; + /** Configures the Azure SQL server to use a specific subnet for deployment scripts */ + withAdminDeploymentScriptSubnet(subnet: AzureSubnetResource): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withAdminDeploymentScriptSubnet(subnet))); + } - /** Gets the UriExpression property */ - uriExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.uriExpression', - { context: this._handle } - ); - }, - }; + /** Configures the Azure SQL server to use a specific storage account for deployment scripts */ + withAdminDeploymentScriptStorage(storage: AzureStorageResource): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withAdminDeploymentScriptStorage(storage))); + } - /** Gets the JdbcConnectionString property */ - jdbcConnectionString = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.jdbcConnectionString', - { context: this._handle } - ); - }, - }; + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } - /** Gets the Name property */ - name = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlDatabaseResource.name', - { context: this._handle } - ); - }, - }; + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } - /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new AzureSqlDatabaseResource(result, this._client); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameter(name))); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withContainerRegistryInternal(registry)); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); } - /** @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 AzureSqlDatabaseResource(result, this._client); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlDatabaseResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureSqlDatabaseResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } - /** @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 AzureSqlDatabaseResource(result, this._client); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlDatabaseResourcePromise { - const helpLink = options?.helpLink; - return new AzureSqlDatabaseResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } - /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', - rpcArgs - ); - return new AzureSqlDatabaseResource(result, this._client); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); } - /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', - rpcArgs - ); - return new AzureSqlDatabaseResource(result, this._client); + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } - /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', - rpcArgs - ); - return new AzureSqlDatabaseResource(result, this._client); + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureSqlServerResourcePromise { + return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new AzureSqlDatabaseResource(result, this._client); - } +} - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); +// ============================================================================ +// AzureStorageEmulatorResource +// ============================================================================ + +export class AzureStorageEmulatorResource extends ResourceBuilderBase { + constructor(handle: AzureStorageEmulatorResourceHandle, client: AspireClientRpc) { + super(handle, client); } /** @internal */ - private async _withUrlInternal(url: string, 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', + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureSqlDatabaseResourcePromise { - const displayText = options?.displayText; - return new AzureSqlDatabaseResourcePromise(this._withUrlInternal(url, displayText)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlDatabaseResourcePromise { - const displayText = options?.displayText; - return new AzureSqlDatabaseResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): AzureStorageEmulatorResourcePromise { + const isReadOnly = options?.isReadOnly; + return new AzureStorageEmulatorResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); } /** @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', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEntrypointInternal(entrypoint)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._excludeFromManifestInternal()); + /** Sets the container image tag */ + withImageTag(tag: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withImageTagInternal(tag)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withExplicitStartInternal()); + /** Sets the container image registry */ + withImageRegistry(registry: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withImageRegistryInternal(registry)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withHealthCheckInternal(key)); + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): AzureStorageEmulatorResourcePromise { + const tag = options?.tag; + return new AzureStorageEmulatorResourcePromise(this._withImageInternal(image, tag)); } /** @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 ExecuteCommandContext(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', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlDatabaseResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureSqlDatabaseResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withImageSHA256Internal(sha256)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withParentRelationshipInternal(parent)); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withContainerRuntimeArgsInternal(args)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withChildRelationshipInternal(child)); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withLifetimeInternal(lifetime)); } /** @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', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlDatabaseResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureSqlDatabaseResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { + private async _publishAsContainerInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', rpcArgs ); - return new AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._excludeFromMcpInternal()); + /** Configures the resource to be published as a container */ + publishAsContainer(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._publishAsContainerInternal()); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): AzureStorageEmulatorResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new AzureStorageEmulatorResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Sets the container name */ + withContainerName(name: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withContainerNameInternal(name)); } /** @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 PipelineStepContext(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', + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', rpcArgs ); - return new AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlDatabaseResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureSqlDatabaseResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withBuildArgInternal(name, value)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); - return new AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withBuildSecretInternal(name, value)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureStorageEmulatorResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new AzureStorageEmulatorResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @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 AzureStorageEmulatorResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } /** @internal */ - private async _withDefaultAzureSkuInternal(): Promise { + private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Sql/withDefaultAzureSku', + if (buildImage !== undefined) rpcArgs.buildImage = buildImage; + if (runtimeImage !== undefined) rpcArgs.runtimeImage = runtimeImage; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures the Azure SQL database to use the default Azure SKU */ - withDefaultAzureSku(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withDefaultAzureSkuInternal()); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageEmulatorResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureStorageEmulatorResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + 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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withContainerNetworkAliasInternal(alias)); } -} - -/** - * Thenable wrapper for AzureSqlDatabaseResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class AzureSqlDatabaseResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: AzureSqlDatabaseResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); + /** @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 AzureStorageEmulatorResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzureStorageEmulatorResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new AzureStorageEmulatorResourcePromise(this._withMcpServerInternal(path, endpointName)); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + /** @internal */ + private async _withOtlpExporterInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporter', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Configures OTLP telemetry export */ + withOtlpExporter(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withOtlpExporterInternal()); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); + /** @internal */ + private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { + const rpcArgs: Record = { builder: this._handle, protocol }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withOtlpExporterProtocol', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** @internal */ + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsConnectionString', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._publishAsConnectionStringInternal()); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** @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 AzureStorageEmulatorResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageEmulatorResourcePromise { + const helpLink = options?.helpLink; + return new AzureStorageEmulatorResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** @internal */ + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(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 AzureStorageEmulatorResource(result, this._client); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** @internal */ + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentEndpoint', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** @internal */ + private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, parameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentParameter', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** @internal */ + private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, envVarName, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironmentConnectionString', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** @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 AzureStorageEmulatorResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** Adds arguments */ + withArgs(args: string[]): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withArgsInternal(args)); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** @internal */ + private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; + const obj = new CommandLineArgsCallbackContext(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 AzureStorageEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withArgsCallbackInternal(callback)); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** @internal */ + private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; + const arg = new CommandLineArgsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withArgsCallbackAsync', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures the Azure SQL database to use the default Azure SKU */ - withDefaultAzureSku(): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withDefaultAzureSku())); + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withArgsCallbackAsyncInternal(callback)); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** @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 AzureStorageEmulatorResource(result, this._client); } -} - -// ============================================================================ -// AzureSqlServerResource -// ============================================================================ - -export class AzureSqlServerResource extends ResourceBuilderBase { - constructor(handle: AzureSqlServerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withReferenceEnvironmentInternal(options)); } - /** Gets the HostName property */ - hostName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlServerResource.hostName', - { context: this._handle } - ); - }, - }; - - /** Gets the Port property */ - port = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlServerResource.port', - { context: this._handle } - ); - }, - }; - - /** Gets the UriExpression property */ - uriExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlServerResource.uriExpression', - { context: this._handle } - ); - }, - }; - - /** Gets the ConnectionStringExpression property */ - connectionStringExpression = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlServerResource.connectionStringExpression', - { context: this._handle } - ); - }, - }; + /** @internal */ + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { + 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 AzureStorageEmulatorResource(result, this._client); + } - /** Gets the IsContainer property */ - isContainer = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlServerResource.isContainer', - { context: this._handle } - ); - }, - }; + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzureStorageEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); + } - /** Gets the Databases property */ - private _databases?: AspireDict; - get databases(): AspireDict { - if (!this._databases) { - this._databases = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.Azure/AzureSqlServerResource.databases', - 'Aspire.Hosting.Azure/AzureSqlServerResource.databases' - ); - } - return this._databases; + /** @internal */ + private async _withReferenceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceUri', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Gets the JdbcConnectionString property */ - jdbcConnectionString = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlServerResource.jdbcConnectionString', - { context: this._handle } - ); - }, - }; + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withReferenceUriInternal(name, uri)); + } - /** Gets the Parameters property */ - private _parameters?: AspireDict; - get parameters(): AspireDict { - if (!this._parameters) { - this._parameters = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.Azure/AzureSqlServerResource.parameters', - 'Aspire.Hosting.Azure/AzureSqlServerResource.parameters' - ); - } - return this._parameters; + /** @internal */ + private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { + const rpcArgs: Record = { builder: this._handle, externalService }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceExternalService', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Gets the Outputs property */ - private _outputs?: AspireDict; - get outputs(): AspireDict { - if (!this._outputs) { - this._outputs = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.Azure/AzureSqlServerResource.outputs', - 'Aspire.Hosting.Azure/AzureSqlServerResource.outputs' - ); - } - return this._outputs; + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withReferenceExternalServiceInternal(externalService)); } - /** Gets the SecretOutputs property */ - private _secretOutputs?: AspireDict; - get secretOutputs(): AspireDict { - if (!this._secretOutputs) { - this._secretOutputs = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.Azure/AzureSqlServerResource.secretOutputs', - 'Aspire.Hosting.Azure/AzureSqlServerResource.secretOutputs' - ); - } - return this._secretOutputs; + /** @internal */ + private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, endpointReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEndpoint', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Gets the Name property */ - name = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/AzureSqlServerResource.name', - { context: this._handle } - ); - }, - }; + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withContainerRegistryInternal(registry)); + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): AzureStorageEmulatorResourcePromise { + 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 AzureStorageEmulatorResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): 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', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlServerResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureSqlServerResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageEmulatorResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new AzureStorageEmulatorResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); } /** @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', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlServerResourcePromise { - const helpLink = options?.helpLink; - return new AzureSqlServerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageEmulatorResourcePromise { + const port = options?.port; + const targetPort = options?.targetPort; + const name = options?.name; + const env = options?.env; + const isProxied = options?.isProxied; + return new AzureStorageEmulatorResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', + private async _withExternalHttpEndpointsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExternalHttpEndpoints', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withExternalHttpEndpointsInternal()); + } + + /** Gets an endpoint reference */ + async getEndpoint(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getEndpoint', + rpcArgs + ); } /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._asHttp2ServiceInternal()); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureSqlServerResourcePromise { + withUrl(url: string, options?: WithUrlOptions): AzureStorageEmulatorResourcePromise { const displayText = options?.displayText; - return new AzureSqlServerResourcePromise(this._withUrlInternal(url, displayText)); + return new AzureStorageEmulatorResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlServerResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageEmulatorResourcePromise { const displayText = options?.displayText; - return new AzureSqlServerResourcePromise(this._withUrlExpressionInternal(url, displayText)); - } - - /** @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 AzureSqlServerResource(result, this._client); - } - - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); - } - - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new AzureSqlServerResource(result, this._client); - } - - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._excludeFromManifestInternal()); + return new AzureStorageEmulatorResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withExplicitStartInternal()); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withHealthCheckInternal(key)); + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); } /** @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 ExecuteCommandContext(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', + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlServerResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureSqlServerResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _waitForInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResource', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParentRelationshipInternal(parent)); + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._waitForInternal(dependency)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForWithBehavior', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withChildRelationshipInternal(child)); + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); } /** @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', + private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, dependency }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlServerResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureSqlServerResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._waitForStartInternal(dependency)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { + const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/waitForStartWithBehavior', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._excludeFromMcpInternal()); + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): AzureStorageEmulatorResourcePromise { + const exitCode = options?.exitCode; + return new AzureStorageEmulatorResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); } /** @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 PipelineStepContext(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', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlServerResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureSqlServerResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds a health check by key */ + withHealthCheck(key: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageEmulatorResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new AzureStorageEmulatorResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + 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 ExecuteCommandContext(argHandle, this._client); + return await executeCommand(arg); }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageEmulatorResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureStorageEmulatorResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @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 AzureStorageEmulatorResource(result, 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.Azure.Sql/addDatabase', + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + } + + /** @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 AzureSqlDatabaseResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds an Azure SQL database resource */ - addDatabase(name: string, options?: AddDatabaseOptions): AzureSqlDatabaseResourcePromise { - const databaseName = options?.databaseName; - return new AzureSqlDatabaseResourcePromise(this._addDatabaseInternal(name, databaseName)); + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withCertificateTrustScopeInternal(scope)); } /** @internal */ - private async _runAsContainerInternal(configureContainer?: (obj: SqlServerServerResource) => Promise): Promise { - const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as SqlServerServerResourceHandle; - const obj = new SqlServerServerResource(objHandle, this._client); - await configureContainer(obj); - }) : undefined; + private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle }; - if (configureContainer !== undefined) rpcArgs.configureContainer = configureContainerId; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Sql/runAsContainer', + if (password !== undefined) rpcArgs.password = password; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures the Azure SQL server to run locally in a SQL Server container */ - runAsContainer(options?: RunAsContainerOptions): AzureSqlServerResourcePromise { - const configureContainer = options?.configureContainer; - return new AzureSqlServerResourcePromise(this._runAsContainerInternal(configureContainer)); + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): AzureStorageEmulatorResourcePromise { + const password = options?.password; + return new AzureStorageEmulatorResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); } /** @internal */ - private async _withAdminDeploymentScriptStorageInternal(storage: AzureStorageResource): Promise { - const rpcArgs: Record = { builder: this._handle, storage }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Sql/withAdminDeploymentScriptStorage', + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures the Azure SQL server to use a specific storage account for deployment scripts */ - withAdminDeploymentScriptStorage(storage: AzureStorageResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withAdminDeploymentScriptStorageInternal(storage)); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withoutHttpsCertificateInternal()); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } - /** Gets an output reference from an Azure Bicep template resource */ - async getOutput(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/getOutput', + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withParameterInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameter', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter without a value */ - withParameter(name: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterInternal(name)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withParameterStringValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterStringValue', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterStringValueInternal(name, value)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageEmulatorResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureStorageEmulatorResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterStringValues', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterStringValuesInternal(name, value)); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageEmulatorResourcePromise { + 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 AzureStorageEmulatorResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ - private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromParameter', + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterFromParameterInternal(name, value)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromConnectionString', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); } /** @internal */ - private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromOutput', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterFromOutputInternal(name, value)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); } /** @internal */ - private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + 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 PipelineStepContext(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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageEmulatorResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureStorageEmulatorResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromEndpoint', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._withParameterFromEndpointInternal(name, value)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; - const obj = new AzureResourceInfrastructure(objHandle, this._client); - await configure(obj); + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(objHandle, this._client); + await callback(obj); }); - const rpcArgs: Record = { builder: this._handle, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/configureInfrastructure', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures the Azure provisioning infrastructure callback */ - configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._configureInfrastructureInternal(configure)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsConnectionString', + 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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._publishAsConnectionStringInternal()); + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): AzureStorageEmulatorResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new AzureStorageEmulatorResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); } - /** Gets the normalized Bicep identifier for an Azure resource */ - async getBicepIdentifier(): Promise { + /** Gets the resource name */ + async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/getBicepIdentifier', + 'Aspire.Hosting/getResourceName', rpcArgs ); } /** @internal */ - private async _clearDefaultRoleAssignmentsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureSqlServerResource(result, this._client); - } - - /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + return new AzureStorageEmulatorResource(result, this._client); } - /** Determines whether a resource is marked as existing */ - async isExisting(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/isExisting', - rpcArgs - ); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExisting', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._runAsExistingInternal(name, resourceGroup)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExisting', + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureSqlServerResource(result, this._client); + return new AzureStorageEmulatorResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExisting', + private async _withDataBindMountInternal(path?: string, isReadOnly?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (path !== undefined) rpcArgs.path = path; + if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withDataBindMount', rpcArgs ); - return new AzureSqlServerResource(result, this._client); - } - - /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); - } - -} - -/** - * Thenable wrapper for AzureSqlServerResource that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class AzureSqlServerResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: AzureSqlServerResource) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); - } - - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + return new AzureStorageEmulatorResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Adds a bind mount for the data folder to an Azure Storage emulator resource */ + withDataBindMount(options?: WithDataBindMountOptions): AzureStorageEmulatorResourcePromise { + const path = options?.path; + const isReadOnly = options?.isReadOnly; + return new AzureStorageEmulatorResourcePromise(this._withDataBindMountInternal(path, isReadOnly)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @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.Azure.Storage/withDataVolume', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Adds a named volume for the data folder to an Azure Storage emulator resource */ + withDataVolume(options?: WithDataVolumeOptions): AzureStorageEmulatorResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new AzureStorageEmulatorResourcePromise(this._withDataVolumeInternal(name, isReadOnly)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @internal */ + private async _withBlobPortInternal(port: number): Promise { + const rpcArgs: Record = { builder: this._handle, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withBlobPort', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Sets the host port for blob requests on the storage emulator */ + withBlobPort(port: number): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withBlobPortInternal(port)); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** @internal */ + private async _withQueuePortInternal(port: number): Promise { + const rpcArgs: Record = { builder: this._handle, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withQueuePort', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Sets the host port for queue requests on the storage emulator */ + withQueuePort(port: number): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withQueuePortInternal(port)); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @internal */ + private async _withTablePortInternal(port: number): Promise { + const rpcArgs: Record = { builder: this._handle, port }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withTablePort', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Sets the host port for table requests on the storage emulator */ + withTablePort(port: number): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withTablePortInternal(port)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _withApiVersionCheckInternal(enable?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle }; + if (enable !== undefined) rpcArgs.enable = enable; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withApiVersionCheck', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** Configures whether the emulator checks API version validity */ + withApiVersionCheck(options?: WithApiVersionCheckOptions): AzureStorageEmulatorResourcePromise { + const enable = options?.enable; + return new AzureStorageEmulatorResourcePromise(this._withApiVersionCheckInternal(enable)); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** @internal */ + private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withEnvironmentFromOutput', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Sets an environment variable from a Bicep output reference */ + withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentFromOutputInternal(name, bicepOutputReference)); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** @internal */ + private async _withEnvironmentFromKeyVaultSecretInternal(name: string, secretReference: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, secretReference }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withEnvironmentFromKeyVaultSecret', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Sets an environment variable from an Azure Key Vault secret reference */ + withEnvironmentFromKeyVaultSecret(name: string, secretReference: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentFromKeyVaultSecretInternal(name, secretReference)); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** @internal */ + private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { + const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder)); } - /** Adds an Azure SQL database resource */ - addDatabase(name: string, options?: AddDatabaseOptions): AzureSqlDatabaseResourcePromise { - return new AzureSqlDatabaseResourcePromise(this._promise.then(obj => obj.addDatabase(name, options))); - } +} - /** Configures the Azure SQL server to run locally in a SQL Server container */ - runAsContainer(options?: RunAsContainerOptions): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.runAsContainer(options))); - } +/** + * Thenable wrapper for AzureStorageEmulatorResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureStorageEmulatorResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Configures the Azure SQL server to use a specific storage account for deployment scripts */ - withAdminDeploymentScriptStorage(storage: AzureStorageResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withAdminDeploymentScriptStorage(storage))); + then( + onfulfilled?: ((value: AzureStorageEmulatorResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** Gets an output reference from an Azure Bicep template resource */ - getOutput(name: string): Promise { - return this._promise.then(obj => obj.getOutput(name)); + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); } - /** Adds a Bicep parameter without a value */ - withParameter(name: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameter(name))); + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); } - /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + /** Sets the container image tag */ + withImageTag(tag: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); } - /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + /** Sets the container image registry */ + withImageRegistry(registry: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); } - /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImage(image, options))); } - /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); } - /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); } - /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); } - /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); } - /** Configures the Azure provisioning infrastructure callback */ - configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + /** Configures the resource to be published as a container */ + publishAsContainer(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.publishAsContainer())); } - /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); } - /** Gets the normalized Bicep identifier for an Azure resource */ - getBicepIdentifier(): Promise { - return this._promise.then(obj => obj.getBicepIdentifier()); + /** Sets the container name */ + withContainerName(name: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } - /** Determines whether a resource is marked as existing */ - isExisting(): Promise { - return this._promise.then(obj => obj.isExisting()); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); } - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); } - /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSqlServerResourcePromise { - return new AzureSqlServerResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); } -} - -// ============================================================================ -// AzureStorageEmulatorResource -// ============================================================================ - -export class AzureStorageEmulatorResource extends ResourceBuilderBase { - constructor(handle: AzureStorageEmulatorResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Configures OTLP telemetry export */ + withOtlpExporter(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); } - /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Configures OTLP telemetry export with specific protocol */ + withOtlpExporterProtocol(protocol: OtlpProtocol): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withContainerRegistryInternal(registry)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): AzureStorageEmulatorResourcePromise { - const isReadOnly = options?.isReadOnly; - return new AzureStorageEmulatorResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEntrypointInternal(entrypoint)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Sets an environment variable from a parameter resource */ + withEnvironmentParameter(name: string, parameter: ParameterResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); } - /** Sets the container image tag */ - withImageTag(tag: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withImageTagInternal(tag)); + /** Sets an environment variable from a connection string resource */ + withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds arguments */ + withArgs(args: string[]): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withArgs(args))); } - /** Sets the container image registry */ - withImageRegistry(registry: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withImageRegistryInternal(registry)); + /** Sets command-line arguments via callback */ + withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Sets command-line arguments via async callback */ + withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): AzureStorageEmulatorResourcePromise { - const tag = options?.tag; - return new AzureStorageEmulatorResourcePromise(this._withImageInternal(image, tag)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Sets the image SHA256 digest */ - withImageSHA256(sha256: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withImageSHA256Internal(sha256)); + /** Adds a reference to a URI */ + withReferenceUri(name: string, uri: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds a reference to an external service */ + withReferenceExternalService(externalService: ExternalServiceResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); } - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withContainerRuntimeArgsInternal(args)); + /** Adds a reference to an endpoint */ + withReferenceEndpoint(endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); } - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withLifetimeInternal(lifetime)); + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); } - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); } - /** @internal */ - private async _publishAsContainerInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishAsContainer', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); } - /** Configures the resource to be published as a container */ - publishAsContainer(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._publishAsContainerInternal()); + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.asHttp2Service())); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** Configures the resource to use a Dockerfile */ - withDockerfile(contextPath: string, options?: WithDockerfileOptions): AzureStorageEmulatorResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new AzureStorageEmulatorResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } - /** Sets the container name */ - withContainerName(name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withContainerNameInternal(name)); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } - /** @internal */ - private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildArg', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withBuildArgInternal(name, value)); + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); } - /** @internal */ - private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } - /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withBuildSecretInternal(name, value)); + /** Waits for another resource to be ready */ + waitFor(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Waits for another resource with specific behavior */ + waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); } - /** Configures endpoint proxy support */ - withEndpointProxySupport(proxyEnabled: boolean): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + /** Waits for another resource to start */ + waitForStart(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Waits for another resource to start with specific behavior */ + waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageEmulatorResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureStorageEmulatorResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Waits for resource completion */ + waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); } - /** Adds a network alias for the container */ - withContainerNetworkAlias(alias: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withContainerNetworkAliasInternal(alias)); + /** Adds a health check by key */ + withHealthCheck(key: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); } - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): AzureStorageEmulatorResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new AzureStorageEmulatorResourcePromise(this._withMcpServerInternal(path, endpointName)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** @internal */ - private async _withOtlpExporterInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporter', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Configures developer certificate trust */ + withDeveloperCertificateTrust(trust: boolean): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); } - /** Configures OTLP telemetry export */ - withOtlpExporter(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withOtlpExporterInternal()); + /** Sets the certificate trust scope */ + withCertificateTrustScope(scope: CertificateTrustScope): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); } - /** @internal */ - private async _withOtlpExporterProtocolInternal(protocol: OtlpProtocol): Promise { - const rpcArgs: Record = { builder: this._handle, protocol }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withOtlpExporterProtocol', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Configures HTTPS with a developer certificate */ + withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); } - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withOtlpExporterProtocolInternal(protocol)); + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } - /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishAsConnectionString', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } - /** Publishes the resource as a connection string */ - publishAsConnectionString(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._publishAsConnectionStringInternal()); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageEmulatorResourcePromise { - const helpLink = options?.helpLink; - return new AzureStorageEmulatorResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); } - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); } - /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } - /** @internal */ - private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, parameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentParameter', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: ParameterResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentParameterInternal(name, parameter)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** @internal */ - private async _withEnvironmentConnectionStringInternal(envVarName: string, resource: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, envVarName, resource }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentConnectionString', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentConnectionStringInternal(envVarName, resource)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** @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 AzureStorageEmulatorResource(result, this._client); + /** Adds a bind mount for the data folder to an Azure Storage emulator resource */ + withDataBindMount(options?: WithDataBindMountOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDataBindMount(options))); } - /** Adds arguments */ - withArgs(args: string[]): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withArgsInternal(args)); + /** Adds a named volume for the data folder to an Azure Storage emulator resource */ + withDataVolume(options?: WithDataVolumeOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); } - /** @internal */ - private async _withArgsCallbackInternal(callback: (obj: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as CommandLineArgsCallbackContextHandle; - const obj = new CommandLineArgsCallbackContext(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 AzureStorageEmulatorResource(result, this._client); + /** Sets the host port for blob requests on the storage emulator */ + withBlobPort(port: number): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBlobPort(port))); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withArgsCallbackInternal(callback)); + /** Sets the host port for queue requests on the storage emulator */ + withQueuePort(port: number): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withQueuePort(port))); } - /** @internal */ - private async _withArgsCallbackAsyncInternal(callback: (arg: CommandLineArgsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as CommandLineArgsCallbackContextHandle; - const arg = new CommandLineArgsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withArgsCallbackAsync', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Sets the host port for table requests on the storage emulator */ + withTablePort(port: number): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withTablePort(port))); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withArgsCallbackAsyncInternal(callback)); + /** Configures whether the emulator checks API version validity */ + withApiVersionCheck(options?: WithApiVersionCheckOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withApiVersionCheck(options))); } - /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzureStorageEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Sets an environment variable from a Bicep output reference */ + withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); + } + + /** Sets an environment variable from an Azure Key Vault secret reference */ + withEnvironmentFromKeyVaultSecret(name: string, secretReference: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentFromKeyVaultSecret(name, secretReference))); } - /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReference', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); + /** Associates an Azure user-assigned identity with a compute resource */ + withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withServiceReferenceInternal(source)); +} + +// ============================================================================ +// AzureStorageResource +// ============================================================================ + +export class AzureStorageResource extends ResourceBuilderBase { + constructor(handle: AzureStorageResourceHandle, client: AspireClientRpc) { + super(handle, client); } /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withReferenceUriInternal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceUri', + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withReferenceUriInternal(name, uri)); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withReferenceExternalServiceInternal(externalService: ExternalServiceResource): Promise { - const rpcArgs: Record = { builder: this._handle, externalService }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceExternalService', + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withReferenceExternalServiceInternal(externalService)); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzureStorageResourcePromise { + const path = options?.path; + const endpointName = options?.endpointName; + return new AzureStorageResourcePromise(this._withMcpServerInternal(path, endpointName)); } /** @internal */ - private async _withReferenceEndpointInternal(endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, endpointReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReferenceEndpoint', + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withReferenceEndpointInternal(endpointReference)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageResourcePromise { + const helpLink = options?.helpLink; + return new AzureStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEndpointInternal(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): Promise { + 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; @@ -10476,15 +19581,15 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withEndpoint', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): AzureStorageEmulatorResourcePromise { + withEndpoint(options?: WithEndpointOptions): AzureStorageResourcePromise { const port = options?.port; const targetPort = options?.targetPort; const scheme = options?.scheme; @@ -10493,72 +19598,72 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHttpEndpoint', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageEmulatorResourcePromise { + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageResourcePromise { const port = options?.port; const targetPort = options?.targetPort; const name = options?.name; const env = options?.env; const isProxied = options?.isProxied; - return new AzureStorageEmulatorResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + return new AzureStorageResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHttpsEndpoint', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageEmulatorResourcePromise { + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageResourcePromise { const port = options?.port; const targetPort = options?.targetPort; const name = options?.name; const env = options?.env; const isProxied = options?.isProxied; - return new AzureStorageEmulatorResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + return new AzureStorageResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); } /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { + private async _withExternalHttpEndpointsInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExternalHttpEndpoints', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withExternalHttpEndpointsInternal()); + withExternalHttpEndpoints(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withExternalHttpEndpointsInternal()); } /** Gets an endpoint reference */ @@ -10571,2379 +19676,2693 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + private async _asHttp2ServiceInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/asHttp2Service', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._asHttp2ServiceInternal()); + } + + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + } + + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureStorageResource(result, this._client); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureStorageResourcePromise { + const displayText = options?.displayText; + return new AzureStorageResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageResourcePromise { + const displayText = options?.displayText; + return new AzureStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureStorageResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; + const arg = new EndpointReference(argHandle, this._client); + return await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlForEndpointFactory', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._excludeFromManifestInternal()); + } + + /** @internal */ + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._asHttp2ServiceInternal()); + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Adds a health check by key */ + withHealthCheck(key: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageResourcePromise { + const path = options?.path; + const statusCode = options?.statusCode; + const endpointName = options?.endpointName; + return new AzureStorageResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); } /** @internal */ - private async _withUrlInternal(url: string, 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', + 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 ExecuteCommandContext(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureStorageEmulatorResourcePromise { - const displayText = options?.displayText; - return new AzureStorageEmulatorResourcePromise(this._withUrlInternal(url, displayText)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageEmulatorResourcePromise { - const displayText = options?.displayText; - return new AzureStorageEmulatorResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @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', + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._excludeFromManifestInternal()); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _waitForInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._waitForInternal(dependency)); + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageResourcePromise { + 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 AzureStorageResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); } /** @internal */ - private async _waitForWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForWithBehavior', + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._waitForWithBehaviorInternal(dependency, waitBehavior)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 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 PipelineStepContext(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._waitForStartInternal(dependency)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _waitForStartWithBehaviorInternal(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): Promise { - const rpcArgs: Record = { builder: this._handle, dependency, waitBehavior }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStartWithBehavior', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._waitForStartWithBehaviorInternal(dependency, waitBehavior)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withExplicitStartInternal()); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); } /** @internal */ - private async _waitForCompletionInternal(dependency: ResourceBuilderBase, exitCode?: number): Promise { - const rpcArgs: Record = { builder: this._handle, dependency }; - if (exitCode !== undefined) rpcArgs.exitCode = exitCode; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): AzureStorageEmulatorResourcePromise { - const exitCode = options?.exitCode; - return new AzureStorageEmulatorResourcePromise(this._waitForCompletionInternal(dependency, exitCode)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withHealthCheckInternal(key)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceStoppedInternal(callback)); } /** @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', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageEmulatorResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new AzureStorageEmulatorResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onInitializeResourceInternal(callback)); } /** @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 ExecuteCommandContext(argHandle, this._client); - return await executeCommand(arg); + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(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', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageEmulatorResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureStorageEmulatorResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _withDeveloperCertificateTrustInternal(trust: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, trust }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withDeveloperCertificateTrust', + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withDeveloperCertificateTrustInternal(trust)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ - private async _withCertificateTrustScopeInternal(scope: CertificateTrustScope): Promise { - const rpcArgs: Record = { builder: this._handle, scope }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withCertificateTrustScope', + private async _runAsEmulatorInternal(configureContainer?: (obj: AzureStorageEmulatorResource) => Promise): Promise { + const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureStorageEmulatorResourceHandle; + const obj = new AzureStorageEmulatorResource(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.Storage/runAsEmulator', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withCertificateTrustScopeInternal(scope)); + /** Configures the Azure Storage resource to be emulated using Azurite */ + runAsEmulator(options?: RunAsEmulatorOptions): AzureStorageResourcePromise { + const configureContainer = options?.configureContainer; + return new AzureStorageResourcePromise(this._runAsEmulatorInternal(configureContainer)); } /** @internal */ - private async _withHttpsDeveloperCertificateInternal(password?: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (password !== undefined) rpcArgs.password = password; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + private async _addBlobsInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addBlobs', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureBlobStorageResource(result, this._client); } - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): AzureStorageEmulatorResourcePromise { - const password = options?.password; - return new AzureStorageEmulatorResourcePromise(this._withHttpsDeveloperCertificateInternal(password)); + /** Adds an Azure Blob Storage resource */ + addBlobs(name: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._addBlobsInternal(name)); } /** @internal */ - private async _withoutHttpsCertificateInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', + private async _addDataLakeInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addDataLake', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureDataLakeStorageResource(result, this._client); } - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withoutHttpsCertificateInternal()); + /** Adds an Azure Data Lake Storage resource */ + addDataLake(name: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._addDataLakeInternal(name)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _addBlobContainerInternal(name: string, blobContainerName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (blobContainerName !== undefined) rpcArgs.blobContainerName = blobContainerName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addBlobContainer', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureBlobStorageContainerResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withParentRelationshipInternal(parent)); + /** Adds an Azure Blob Storage container resource */ + addBlobContainer(name: string, options?: AddBlobContainerOptions): AzureBlobStorageContainerResourcePromise { + const blobContainerName = options?.blobContainerName; + return new AzureBlobStorageContainerResourcePromise(this._addBlobContainerInternal(name, blobContainerName)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + private async _addDataLakeFileSystemInternal(name: string, dataLakeFileSystemName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (dataLakeFileSystemName !== undefined) rpcArgs.dataLakeFileSystemName = dataLakeFileSystemName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addDataLakeFileSystem', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureDataLakeStorageFileSystemResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds an Azure Data Lake Storage file system resource */ + addDataLakeFileSystem(name: string, options?: AddDataLakeFileSystemOptions): AzureDataLakeStorageFileSystemResourcePromise { + const dataLakeFileSystemName = options?.dataLakeFileSystemName; + return new AzureDataLakeStorageFileSystemResourcePromise(this._addDataLakeFileSystemInternal(name, dataLakeFileSystemName)); } /** @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', + private async _addTablesInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addTables', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageEmulatorResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureStorageEmulatorResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Adds an Azure Table Storage resource */ + addTables(name: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._addTablesInternal(name)); } /** @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', + private async _addQueuesInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addQueues', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureQueueStorageResource(result, this._client); } - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageEmulatorResourcePromise { - 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 AzureStorageEmulatorResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + /** Adds an Azure Queue Storage resource */ + addQueues(name: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._addQueuesInternal(name)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + private async _addQueueInternal(name: string, queueName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (queueName !== undefined) rpcArgs.queueName = queueName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addQueue', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureQueueStorageQueueResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._excludeFromMcpInternal()); + /** Adds an Azure Storage queue resource */ + addQueue(name: string, options?: AddQueueOptions): AzureQueueStorageQueueResourcePromise { + const queueName = options?.queueName; + return new AzureQueueStorageQueueResourcePromise(this._addQueueInternal(name, queueName)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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 _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterInternal(name)); } /** @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 PipelineStepContext(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', + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageEmulatorResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureStorageEmulatorResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterStringValueInternal(name, value)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterStringValuesInternal(name, value)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterFromParameterInternal(name, value)); } /** @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', + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): AzureStorageEmulatorResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new AzureStorageEmulatorResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); + return new AzureStorageResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterFromOutputInternal(name, value)); } /** @internal */ - private async _withDataBindMountInternal(path?: string, isReadOnly?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle }; - if (path !== undefined) rpcArgs.path = path; - if (isReadOnly !== undefined) rpcArgs.isReadOnly = isReadOnly; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withDataBindMount', + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a bind mount for the data folder to an Azure Storage emulator resource */ - withDataBindMount(options?: WithDataBindMountOptions): AzureStorageEmulatorResourcePromise { - const path = options?.path; - const isReadOnly = options?.isReadOnly; - return new AzureStorageEmulatorResourcePromise(this._withDataBindMountInternal(path, isReadOnly)); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } /** @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.Azure.Storage/withDataVolume', + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Adds a named volume for the data folder to an Azure Storage emulator resource */ - withDataVolume(options?: WithDataVolumeOptions): AzureStorageEmulatorResourcePromise { - const name = options?.name; - const isReadOnly = options?.isReadOnly; - return new AzureStorageEmulatorResourcePromise(this._withDataVolumeInternal(name, isReadOnly)); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withParameterFromEndpointInternal(name, value)); } /** @internal */ - private async _withBlobPortInternal(port: number): Promise { - const rpcArgs: Record = { builder: this._handle, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withBlobPort', + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Sets the host port for blob requests on the storage emulator */ - withBlobPort(port: number): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withBlobPortInternal(port)); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._configureInfrastructureInternal(configure)); } /** @internal */ - private async _withQueuePortInternal(port: number): Promise { - const rpcArgs: Record = { builder: this._handle, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withQueuePort', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Sets the host port for queue requests on the storage emulator */ - withQueuePort(port: number): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withQueuePortInternal(port)); + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._publishAsConnectionStringInternal()); } - /** @internal */ - private async _withTablePortInternal(port: number): Promise { - const rpcArgs: Record = { builder: this._handle, port }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withTablePort', + /** Gets the normalized Bicep identifier for an Azure resource */ + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Sets the host port for table requests on the storage emulator */ - withTablePort(port: number): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withTablePortInternal(port)); } /** @internal */ - private async _withApiVersionCheckInternal(enable?: boolean): Promise { + private async _clearDefaultRoleAssignmentsInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - if (enable !== undefined) rpcArgs.enable = enable; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withApiVersionCheck', + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Configures whether the emulator checks API version validity */ - withApiVersionCheck(options?: WithApiVersionCheckOptions): AzureStorageEmulatorResourcePromise { - const enable = options?.enable; - return new AzureStorageEmulatorResourcePromise(this._withApiVersionCheckInternal(enable)); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._clearDefaultRoleAssignmentsInternal()); } - /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + /** Determines whether a resource is marked as existing */ + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', rpcArgs ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } /** @internal */ - private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withEnvironmentFromOutput', + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Sets an environment variable from a Bicep output reference */ - withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentFromOutputInternal(name, bicepOutputReference)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureStorageResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureStorageResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _withEnvironmentFromKeyVaultSecretInternal(name: string, secretReference: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, name, secretReference }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withEnvironmentFromKeyVaultSecret', + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Sets an environment variable from an Azure Key Vault secret reference */ - withEnvironmentFromKeyVaultSecret(name: string, secretReference: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentFromKeyVaultSecretInternal(name, secretReference)); + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureStorageResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureStorageResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { - const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureStorageEmulatorResource(result, this._client); + return new AzureStorageResource(result, this._client); } - /** Associates an Azure user-assigned identity with a compute resource */ - withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withAzureUserAssignedIdentityInternal(identityResourceBuilder)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureStorageResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureStorageResourcePromise(this._asExistingInternal(name, resourceGroup)); } } /** - * Thenable wrapper for AzureStorageEmulatorResource that enables fluent chaining. + * Thenable wrapper for AzureStorageResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureStorageEmulatorResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureStorageResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureStorageEmulatorResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureStorageResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** Adds a bind mount */ - withBindMount(source: string, target: string, options?: WithBindMountOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** Sets the container entrypoint */ - withEntrypoint(entrypoint: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + /** Configures an MCP server endpoint on the resource */ + withMcpServer(options?: WithMcpServerOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); } - /** Sets the container image tag */ - withImageTag(tag: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets the container image registry */ - withImageRegistry(registry: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + /** Adds a network endpoint */ + withEndpoint(options?: WithEndpointOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); } - /** Sets the container image */ - withImage(image: string, options?: WithImageOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + /** Adds an HTTP endpoint */ + withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); } - /** Sets the image SHA256 digest */ - withImageSHA256(sha256: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + /** Adds an HTTPS endpoint */ + withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); } - /** Adds runtime arguments for the container */ - withContainerRuntimeArgs(args: string[]): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + /** Makes HTTP endpoints externally accessible */ + withExternalHttpEndpoints(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); } - /** Sets the lifetime behavior of the container resource */ - withLifetime(lifetime: ContainerLifetime): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + /** Gets an endpoint reference */ + getEndpoint(name: string): Promise { + return this._promise.then(obj => obj.getEndpoint(name)); } - /** Sets the container image pull policy */ - withImagePullPolicy(pullPolicy: ImagePullPolicy): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + /** Configures resource for HTTP/2 */ + asHttp2Service(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + } + + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Adds a URL for a specific endpoint via factory callback */ + withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds an HTTP health check */ + withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Adds an HTTP health probe to the resource */ + withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); } - /** Configures the resource to be published as a container */ - publishAsContainer(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** Configures the resource to use a Dockerfile */ - withDockerfile(contextPath: string, options?: WithDockerfileOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + /** Configures the Azure Storage resource to be emulated using Azurite */ + runAsEmulator(options?: RunAsEmulatorOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsEmulator(options))); } - /** Sets the container name */ - withContainerName(name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + /** Adds an Azure Blob Storage resource */ + addBlobs(name: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.addBlobs(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + /** Adds an Azure Data Lake Storage resource */ + addDataLake(name: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.addDataLake(name))); } - /** Adds a build secret from a parameter resource */ - withBuildSecret(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + /** Adds an Azure Blob Storage container resource */ + addBlobContainer(name: string, options?: AddBlobContainerOptions): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.addBlobContainer(name, options))); } - /** Configures endpoint proxy support */ - withEndpointProxySupport(proxyEnabled: boolean): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + /** Adds an Azure Data Lake Storage file system resource */ + addDataLakeFileSystem(name: string, options?: AddDataLakeFileSystemOptions): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.addDataLakeFileSystem(name, options))); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + /** Adds an Azure Table Storage resource */ + addTables(name: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.addTables(name))); } - /** Adds a network alias for the container */ - withContainerNetworkAlias(alias: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + /** Adds an Azure Queue Storage resource */ + addQueues(name: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.addQueues(name))); } - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + /** Adds an Azure Storage queue resource */ + addQueue(name: string, options?: AddQueueOptions): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.addQueue(name, options))); } - /** Configures OTLP telemetry export */ - withOtlpExporter(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withOtlpExporter())); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** Configures OTLP telemetry export with specific protocol */ - withOtlpExporterProtocol(protocol: OtlpProtocol): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); } - /** Publishes the resource as a connection string */ - publishAsConnectionString(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameter(name))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); } - /** Sets an environment variable from a parameter resource */ - withEnvironmentParameter(name: string, parameter: ParameterResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); } - /** Sets an environment variable from a connection string resource */ - withEnvironmentConnectionString(envVarName: string, resource: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); } - /** Adds arguments */ - withArgs(args: string[]): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withArgs(args))); + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); } - /** Sets command-line arguments via callback */ - withArgsCallback(callback: (obj: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withArgsCallback(callback))); + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); } - /** Sets command-line arguments via async callback */ - withArgsCallbackAsync(callback: (arg: CommandLineArgsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Adds a reference to a URI */ - withReferenceUri(name: string, uri: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } - /** Adds a reference to an external service */ - withReferenceExternalService(externalService: ExternalServiceResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceExternalService(externalService))); +} + +// ============================================================================ +// AzureSubnetResource +// ============================================================================ + +export class AzureSubnetResource extends ResourceBuilderBase { + constructor(handle: AzureSubnetResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** Adds a reference to an endpoint */ - withReferenceEndpoint(endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEndpoint(endpointReference))); + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withContainerRegistryInternal(registry)); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); + /** @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 AzureSubnetResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSubnetResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureSubnetResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + /** @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 AzureSubnetResource(result, this._client); } - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSubnetResourcePromise { + const helpLink = options?.helpLink; + return new AzureSubnetResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withUrlsCallbackInternal(callback)); + } + + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureSubnetResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureSubnetResourcePromise { + const displayText = options?.displayText; + return new AzureSubnetResourcePromise(this._withUrlInternal(url, displayText)); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSubnetResourcePromise { + const displayText = options?.displayText; + return new AzureSubnetResourcePromise(this._withUrlExpressionInternal(url, displayText)); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** @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 AzureSubnetResource(result, this._client); } - /** Waits for another resource to be ready */ - waitFor(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitFor(dependency))); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } - /** Waits for another resource with specific behavior */ - waitForWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForWithBehavior(dependency, waitBehavior))); + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } - /** Waits for another resource to start */ - waitForStart(dependency: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForStart(dependency))); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._excludeFromManifestInternal()); } - /** Waits for another resource to start with specific behavior */ - waitForStartWithBehavior(dependency: ResourceBuilderBase, waitBehavior: WaitBehavior): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForStartWithBehavior(dependency, waitBehavior))); + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withExplicitStartInternal()); } - /** Waits for resource completion */ - waitForCompletion(dependency: ResourceBuilderBase, options?: WaitForCompletionOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.waitForCompletion(dependency, options))); + /** @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 AzureSubnetResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withHealthCheckInternal(key)); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** @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 ExecuteCommandContext(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 AzureSubnetResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSubnetResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureSubnetResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } - /** Configures developer certificate trust */ - withDeveloperCertificateTrust(trust: boolean): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDeveloperCertificateTrust(trust))); + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } - /** Sets the certificate trust scope */ - withCertificateTrustScope(scope: CertificateTrustScope): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withCertificateTrustScope(scope))); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } - /** Configures HTTPS with a developer certificate */ - withHttpsDeveloperCertificate(options?: WithHttpsDeveloperCertificateOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpsDeveloperCertificate(options))); + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withParentRelationshipInternal(parent)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 AzureSubnetResource(result, this._client); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureSubnetResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureSubnetResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + excludeFromMcp(): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._excludeFromMcpInternal()); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** @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 PipelineStepContext(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 AzureSubnetResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSubnetResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureSubnetResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureSubnetResource(result, this._client); } - /** Adds a volume */ - withVolume(target: string, options?: WithVolumeOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); - } - - /** Adds a bind mount for the data folder to an Azure Storage emulator resource */ - withDataBindMount(options?: WithDataBindMountOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDataBindMount(options))); - } - - /** Adds a named volume for the data folder to an Azure Storage emulator resource */ - withDataVolume(options?: WithDataVolumeOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withDataVolume(options))); - } - - /** Sets the host port for blob requests on the storage emulator */ - withBlobPort(port: number): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBlobPort(port))); - } - - /** Sets the host port for queue requests on the storage emulator */ - withQueuePort(port: number): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withQueuePort(port))); - } - - /** Sets the host port for table requests on the storage emulator */ - withTablePort(port: number): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withTablePort(port))); - } - - /** Configures whether the emulator checks API version validity */ - withApiVersionCheck(options?: WithApiVersionCheckOptions): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withApiVersionCheck(options))); - } - - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); } - /** Sets an environment variable from a Bicep output reference */ - withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureSubnetResource(result, this._client); } - /** Sets an environment variable from an Azure Key Vault secret reference */ - withEnvironmentFromKeyVaultSecret(name: string, secretReference: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentFromKeyVaultSecret(name, secretReference))); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._onBeforeResourceStartedInternal(callback)); } - /** Associates an Azure user-assigned identity with a compute resource */ - withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureSubnetResource(result, this._client); } -} - -// ============================================================================ -// AzureStorageResource -// ============================================================================ - -export class AzureStorageResource extends ResourceBuilderBase { - constructor(handle: AzureStorageResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withContainerRegistryInternal(registry)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._onInitializeResourceInternal(callback)); } /** @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', + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._onResourceReadyInternal(callback)); } /** @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', + private async _addPrivateEndpointInternal(target: ResourceBuilderBase): Promise { + const rpcArgs: Record = { subnet: this._handle, target }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/addPrivateEndpoint', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzurePrivateEndpointResource(result, this._client); } - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): AzureStorageResourcePromise { - const path = options?.path; - const endpointName = options?.endpointName; - return new AzureStorageResourcePromise(this._withMcpServerInternal(path, endpointName)); + /** Adds an Azure Private Endpoint resource to an Azure subnet resource. */ + addPrivateEndpoint(target: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._addPrivateEndpointInternal(target)); } /** @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', + private async _withNatGatewayInternal(natGateway: AzureNatGatewayResource): Promise { + const rpcArgs: Record = { builder: this._handle, natGateway }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/withNatGateway', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageResourcePromise { - const helpLink = options?.helpLink; - return new AzureStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Associates an Azure NAT Gateway resource with an Azure subnet resource. */ + withNatGateway(natGateway: AzureNatGatewayResource): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withNatGatewayInternal(natGateway)); } /** @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', + private async _withNetworkSecurityGroupInternal(nsg: AzureNetworkSecurityGroupResource): Promise { + const rpcArgs: Record = { builder: this._handle, nsg }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/withNetworkSecurityGroup', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): AzureStorageResourcePromise { - 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 AzureStorageResourcePromise(this._withEndpointInternal(port, targetPort, scheme, name, env, isProxied, isExternal, protocol)); + /** Associates an Azure Network Security Group resource with an Azure subnet resource. */ + withNetworkSecurityGroup(nsg: AzureNetworkSecurityGroupResource): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withNetworkSecurityGroupInternal(nsg)); } /** @internal */ - private async _withHttpEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + private async _allowInboundInternal(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): Promise { const rpcArgs: Record = { builder: this._handle }; if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (from !== undefined) rpcArgs.from = from; + if (to !== undefined) rpcArgs.to = to; + if (protocol !== undefined) rpcArgs.protocol = protocol; + if (priority !== undefined) rpcArgs.priority = priority; 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', + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/allowInbound', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageResourcePromise { + /** Adds an inbound allow rule to the Azure subnet resource's Network Security Group. */ + allowInbound(options?: AllowInboundOptions): AzureSubnetResourcePromise { const port = options?.port; - const targetPort = options?.targetPort; + const from = options?.from; + const to = options?.to; + const protocol = options?.protocol; + const priority = options?.priority; const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new AzureStorageResourcePromise(this._withHttpEndpointInternal(port, targetPort, name, env, isProxied)); + return new AzureSubnetResourcePromise(this._allowInboundInternal(port, from, to, protocol, priority, name)); } /** @internal */ - private async _withHttpsEndpointInternal(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): Promise { + private async _denyInboundInternal(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): Promise { const rpcArgs: Record = { builder: this._handle }; if (port !== undefined) rpcArgs.port = port; - if (targetPort !== undefined) rpcArgs.targetPort = targetPort; + if (from !== undefined) rpcArgs.from = from; + if (to !== undefined) rpcArgs.to = to; + if (protocol !== undefined) rpcArgs.protocol = protocol; + if (priority !== undefined) rpcArgs.priority = priority; 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', + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/denyInbound', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageResourcePromise { + /** Adds an inbound deny rule to the Azure subnet resource's Network Security Group. */ + denyInbound(options?: DenyInboundOptions): AzureSubnetResourcePromise { const port = options?.port; - const targetPort = options?.targetPort; + const from = options?.from; + const to = options?.to; + const protocol = options?.protocol; + const priority = options?.priority; const name = options?.name; - const env = options?.env; - const isProxied = options?.isProxied; - return new AzureStorageResourcePromise(this._withHttpsEndpointInternal(port, targetPort, name, env, isProxied)); + return new AzureSubnetResourcePromise(this._denyInboundInternal(port, from, to, protocol, priority, name)); } /** @internal */ - private async _withExternalHttpEndpointsInternal(): Promise { + private async _allowOutboundInternal(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExternalHttpEndpoints', + if (port !== undefined) rpcArgs.port = port; + if (from !== undefined) rpcArgs.from = from; + if (to !== undefined) rpcArgs.to = to; + if (protocol !== undefined) rpcArgs.protocol = protocol; + if (priority !== undefined) rpcArgs.priority = priority; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/allowOutbound', rpcArgs ); - return new AzureStorageResource(result, this._client); - } - - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withExternalHttpEndpointsInternal()); + return new AzureSubnetResource(result, this._client); } - /** Gets an endpoint reference */ - async getEndpoint(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getEndpoint', - rpcArgs - ); + /** Adds an outbound allow rule to the Azure subnet resource's Network Security Group. */ + allowOutbound(options?: AllowOutboundOptions): AzureSubnetResourcePromise { + const port = options?.port; + const from = options?.from; + const to = options?.to; + const protocol = options?.protocol; + const priority = options?.priority; + const name = options?.name; + return new AzureSubnetResourcePromise(this._allowOutboundInternal(port, from, to, protocol, priority, name)); } /** @internal */ - private async _asHttp2ServiceInternal(): Promise { + private async _denyOutboundInternal(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/asHttp2Service', + if (port !== undefined) rpcArgs.port = port; + if (from !== undefined) rpcArgs.from = from; + if (to !== undefined) rpcArgs.to = to; + if (protocol !== undefined) rpcArgs.protocol = protocol; + if (priority !== undefined) rpcArgs.priority = priority; + if (name !== undefined) rpcArgs.name = name; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/denyOutbound', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._asHttp2ServiceInternal()); + /** Adds an outbound deny rule to the Azure subnet resource's Network Security Group. */ + denyOutbound(options?: DenyOutboundOptions): AzureSubnetResourcePromise { + const port = options?.port; + const from = options?.from; + const to = options?.to; + const protocol = options?.protocol; + const priority = options?.priority; + const name = options?.name; + return new AzureSubnetResourcePromise(this._denyOutboundInternal(port, from, to, protocol, priority, name)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureSubnetResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } - /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', - rpcArgs - ); - return new AzureStorageResource(result, this._client); - } +} - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); - } +/** + * Thenable wrapper for AzureSubnetResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureSubnetResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** @internal */ - private async _withUrlInternal(url: string, 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 AzureStorageResource(result, this._client); + then( + onfulfilled?: ((value: AzureSubnetResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureStorageResourcePromise { - const displayText = options?.displayText; - return new AzureStorageResourcePromise(this._withUrlInternal(url, displayText)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } - /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageResourcePromise { - const displayText = options?.displayText; - return new AzureStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** @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 AzureStorageResource(result, this._client); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } - /** @internal */ - private async _withUrlForEndpointFactoryInternal(endpointName: string, callback: (arg: EndpointReference) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EndpointReferenceHandle; - const arg = new EndpointReference(argHandle, this._client); - return await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, endpointName, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlForEndpointFactory', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withUrlForEndpointFactoryInternal(endpointName, callback)); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } - /** @internal */ - private async _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._excludeFromManifestInternal()); - } - - /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + excludeFromManifest(): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } - /** @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 AzureStorageResource(result, this._client); + /** Adds a health check by key */ + withHealthCheck(key: string): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withHealthCheckInternal(key)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** @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 AzureStorageResource(result, this._client); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageResourcePromise { - const path = options?.path; - const statusCode = options?.statusCode; - const endpointName = options?.endpointName; - return new AzureStorageResourcePromise(this._withHttpHealthCheckInternal(path, statusCode, endpointName)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } - /** @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 ExecuteCommandContext(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 AzureStorageResource(result, this._client); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } - /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParentRelationshipInternal(parent)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } - /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withChildRelationshipInternal(child)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } - /** @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 AzureStorageResource(result, this._client); + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } - /** @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 AzureStorageResource(result, this._client); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageResourcePromise { - 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 AzureStorageResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._excludeFromMcpInternal()); + /** Adds an Azure Private Endpoint resource to an Azure subnet resource. */ + addPrivateEndpoint(target: ResourceBuilderBase): AzurePrivateEndpointResourcePromise { + return new AzurePrivateEndpointResourcePromise(this._promise.then(obj => obj.addPrivateEndpoint(target))); } - /** @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 AzureStorageResource(result, this._client); + /** Associates an Azure NAT Gateway resource with an Azure subnet resource. */ + withNatGateway(natGateway: AzureNatGatewayResource): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withNatGateway(natGateway))); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Associates an Azure Network Security Group resource with an Azure subnet resource. */ + withNetworkSecurityGroup(nsg: AzureNetworkSecurityGroupResource): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withNetworkSecurityGroup(nsg))); } - /** @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 AzureStorageResource(result, this._client); + /** Adds an inbound allow rule to the Azure subnet resource's Network Security Group. */ + allowInbound(options?: AllowInboundOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.allowInbound(options))); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Adds an inbound deny rule to the Azure subnet resource's Network Security Group. */ + denyInbound(options?: DenyInboundOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.denyInbound(options))); } - /** @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 PipelineStepContext(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 AzureStorageResource(result, this._client); + /** Adds an outbound allow rule to the Azure subnet resource's Network Security Group. */ + allowOutbound(options?: AllowOutboundOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.allowOutbound(options))); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds an outbound deny rule to the Azure subnet resource's Network Security Group. */ + denyOutbound(options?: DenyOutboundOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.denyOutbound(options))); } - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new AzureStorageResource(result, this._client); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); +} + +// ============================================================================ +// AzureTableStorageResource +// ============================================================================ + +export class AzureTableStorageResource extends ResourceBuilderBase { + constructor(handle: AzureTableStorageResourceHandle, client: AspireClientRpc) { + super(handle, 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 PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withContainerRegistryInternal(registry)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @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 AzureTableStorageResource(result, this._client); + } + + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureTableStorageResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureTableStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _runAsEmulatorInternal(configureContainer?: (obj: AzureStorageEmulatorResource) => Promise): Promise { - const configureContainerId = configureContainer ? registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as AzureStorageEmulatorResourceHandle; - const obj = new AzureStorageEmulatorResource(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.Storage/runAsEmulator', + 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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Configures the Azure Storage resource to be emulated using Azurite */ - runAsEmulator(options?: RunAsEmulatorOptions): AzureStorageResourcePromise { - const configureContainer = options?.configureContainer; - return new AzureStorageResourcePromise(this._runAsEmulatorInternal(configureContainer)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureTableStorageResourcePromise { + const helpLink = options?.helpLink; + return new AzureTableStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _addBlobsInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addBlobs', + 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 AzureBlobStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds an Azure Blob Storage resource */ - addBlobs(name: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._addBlobsInternal(name)); + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); } /** @internal */ - private async _addDataLakeInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addDataLake', + private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withConnectionPropertyValue', rpcArgs ); - return new AzureDataLakeStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds an Azure Data Lake Storage resource */ - addDataLake(name: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._addDataLakeInternal(name)); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + } + + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); } /** @internal */ - private async _addBlobContainerInternal(name: string, blobContainerName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (blobContainerName !== undefined) rpcArgs.blobContainerName = blobContainerName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addBlobContainer', + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureBlobStorageContainerResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds an Azure Blob Storage container resource */ - addBlobContainer(name: string, options?: AddBlobContainerOptions): AzureBlobStorageContainerResourcePromise { - const blobContainerName = options?.blobContainerName; - return new AzureBlobStorageContainerResourcePromise(this._addBlobContainerInternal(name, blobContainerName)); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _addDataLakeFileSystemInternal(name: string, dataLakeFileSystemName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (dataLakeFileSystemName !== undefined) rpcArgs.dataLakeFileSystemName = dataLakeFileSystemName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addDataLakeFileSystem', + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureDataLakeStorageFileSystemResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds an Azure Data Lake Storage file system resource */ - addDataLakeFileSystem(name: string, options?: AddDataLakeFileSystemOptions): AzureDataLakeStorageFileSystemResourcePromise { - const dataLakeFileSystemName = options?.dataLakeFileSystemName; - return new AzureDataLakeStorageFileSystemResourcePromise(this._addDataLakeFileSystemInternal(name, dataLakeFileSystemName)); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _addTablesInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; + private async _withUrlInternal(url: string, displayText?: string): Promise { + const rpcArgs: Record = { builder: this._handle, url }; + if (displayText !== undefined) rpcArgs.displayText = displayText; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addTables', + 'Aspire.Hosting/withUrl', rpcArgs ); return new AzureTableStorageResource(result, this._client); } - /** Adds an Azure Table Storage resource */ - addTables(name: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._addTablesInternal(name)); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureTableStorageResourcePromise { + const displayText = options?.displayText; + return new AzureTableStorageResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _addQueuesInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addQueues', + private async _withUrlExpressionInternal(url: 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/withUrlExpression', rpcArgs ); - return new AzureQueueStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds an Azure Queue Storage resource */ - addQueues(name: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._addQueuesInternal(name)); + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureTableStorageResourcePromise { + const displayText = options?.displayText; + return new AzureTableStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _addQueueInternal(name: string, queueName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (queueName !== undefined) rpcArgs.queueName = queueName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addQueue', + 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 AzureQueueStorageQueueResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds an Azure Storage queue resource */ - addQueue(name: string, options?: AddQueueOptions): AzureQueueStorageQueueResourcePromise { - const queueName = options?.queueName; - return new AzureQueueStorageQueueResourcePromise(this._addQueueInternal(name, queueName)); + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._excludeFromManifestInternal()); } - /** Gets an output reference from an Azure Bicep template resource */ - async getOutput(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/getOutput', + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', rpcArgs ); + return new AzureTableStorageResource(result, this._client); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withParameterInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameter', + 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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter without a value */ - withParameter(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterInternal(name)); + /** Adds a health check by key */ + withHealthCheck(key: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withParameterStringValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterStringValue', + 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 ExecuteCommandContext(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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterStringValueInternal(name, value)); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureTableStorageResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureTableStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterStringValues', + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterStringValuesInternal(name, value)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ - private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromParameter', + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterFromParameterInternal(name, value)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromConnectionString', + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromOutput', + 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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterFromOutputInternal(name, value)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureTableStorageResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureTableStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withParameterFromEndpoint', + 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 PipelineStepContext(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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._withParameterFromEndpointInternal(name, value)); + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureTableStorageResourcePromise { + const dependsOn = options?.dependsOn; + const requiredBy = options?.requiredBy; + const tags = options?.tags; + const description = options?.description; + return new AzureTableStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; - const obj = new AzureResourceInfrastructure(objHandle, this._client); - await configure(obj); + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); }); - const rpcArgs: Record = { builder: this._handle, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/configureInfrastructure', + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Configures the Azure provisioning infrastructure callback */ - configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._configureInfrastructureInternal(configure)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsConnectionString', + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._publishAsConnectionStringInternal()); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); } - /** Gets the normalized Bicep identifier for an Azure resource */ - async getBicepIdentifier(): Promise { + /** Gets the resource name */ + async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/getBicepIdentifier', + 'Aspire.Hosting/getResourceName', rpcArgs ); } /** @internal */ - private async _clearDefaultRoleAssignmentsInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureStorageResource(result, this._client); - } - - /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + return new AzureTableStorageResource(result, this._client); } - /** Determines whether a resource is marked as existing */ - async isExisting(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting.Azure/isExisting', - rpcArgs - ); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExisting', + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._runAsExistingInternal(name, resourceGroup)); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExisting', + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExisting', + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureStorageResource(result, this._client); + return new AzureTableStorageResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } } /** - * Thenable wrapper for AzureStorageResource that enables fluent chaining. + * Thenable wrapper for AzureTableStorageResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureStorageResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureTableStorageResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureStorageResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureTableStorageResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); - } - - /** Configures an MCP server endpoint on the resource */ - withMcpServer(options?: WithMcpServerOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a network endpoint */ - withEndpoint(options?: WithEndpointOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); - } - - /** Adds an HTTP endpoint */ - withHttpEndpoint(options?: WithHttpEndpointOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpEndpoint(options))); - } - - /** Adds an HTTPS endpoint */ - withHttpsEndpoint(options?: WithHttpsEndpointOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpsEndpoint(options))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Makes HTTP endpoints externally accessible */ - withExternalHttpEndpoints(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withExternalHttpEndpoints())); + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } - /** Gets an endpoint reference */ - getEndpoint(name: string): Promise { - return this._promise.then(obj => obj.getEndpoint(name)); + /** Adds a connection property with a string value */ + withConnectionPropertyValue(name: string, value: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } - /** Configures resource for HTTP/2 */ - asHttp2Service(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.asHttp2Service())); + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); - } - - /** Adds a URL for a specific endpoint via factory callback */ - withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpointFactory(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } - /** Adds an HTTP health check */ - withHttpHealthCheck(options?: WithHttpHealthCheckOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpHealthCheck(options))); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); - } - - /** Adds an HTTP health probe to the resource */ - withHttpProbe(probeType: ProbeType, options?: WithHttpProbeOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withHttpProbe(probeType, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -12951,712 +22370,870 @@ export class AzureStorageResourcePromise implements PromiseLike obj.getResourceName()); } - /** Configures the Azure Storage resource to be emulated using Azurite */ - runAsEmulator(options?: RunAsEmulatorOptions): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsEmulator(options))); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); } - /** Adds an Azure Blob Storage resource */ - addBlobs(name: string): AzureBlobStorageResourcePromise { - return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.addBlobs(name))); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); } - /** Adds an Azure Data Lake Storage resource */ - addDataLake(name: string): AzureDataLakeStorageResourcePromise { - return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.addDataLake(name))); + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); } - /** Adds an Azure Blob Storage container resource */ - addBlobContainer(name: string, options?: AddBlobContainerOptions): AzureBlobStorageContainerResourcePromise { - return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.addBlobContainer(name, options))); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); } - /** Adds an Azure Data Lake Storage file system resource */ - addDataLakeFileSystem(name: string, options?: AddDataLakeFileSystemOptions): AzureDataLakeStorageFileSystemResourcePromise { - return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.addDataLakeFileSystem(name, options))); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); } - /** Adds an Azure Table Storage resource */ - addTables(name: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.addTables(name))); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } - /** Adds an Azure Queue Storage resource */ - addQueues(name: string): AzureQueueStorageResourcePromise { - return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.addQueues(name))); +} + +// ============================================================================ +// AzureUserAssignedIdentityResource +// ============================================================================ + +export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + constructor(handle: AzureUserAssignedIdentityResourceHandle, client: AspireClientRpc) { + super(handle, client); } - /** Adds an Azure Storage queue resource */ - addQueue(name: string, options?: AddQueueOptions): AzureQueueStorageQueueResourcePromise { - return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.addQueue(name, options))); + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withContainerRegistryInternal(registry)); } - /** Gets an output reference from an Azure Bicep template resource */ - getOutput(name: string): Promise { - return this._promise.then(obj => obj.getOutput(name)); + /** @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 AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a Bicep parameter without a value */ - withParameter(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameter(name))); + /** Sets the base image for a Dockerfile build */ + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise { + const buildImage = options?.buildImage; + const runtimeImage = options?.runtimeImage; + return new AzureUserAssignedIdentityResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } - /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + /** @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 AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise { + const helpLink = options?.helpLink; + return new AzureUserAssignedIdentityResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } - /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + /** @internal */ + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; + const obj = new ResourceUrlsCallbackContext(objHandle, this._client); + await callback(obj); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallback', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withUrlsCallbackInternal(callback)); } - /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + /** @internal */ + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; + const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withUrlsCallbackAsync', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } - /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + /** @internal */ + private async _withUrlInternal(url: string, 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 AzureUserAssignedIdentityResource(result, this._client); } - /** Configures the Azure provisioning infrastructure callback */ - configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise { + const displayText = options?.displayText; + return new AzureUserAssignedIdentityResourcePromise(this._withUrlInternal(url, displayText)); + } + + /** @internal */ + private async _withUrlExpressionInternal(url: 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/withUrlExpression', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureUserAssignedIdentityResourcePromise { + const displayText = options?.displayText; + return new AzureUserAssignedIdentityResourcePromise(this._withUrlExpressionInternal(url, displayText)); + } + + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + } + + /** @internal */ + private async _excludeFromManifestInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromManifest', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._excludeFromManifestInternal()); } - /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + /** @internal */ + private async _withExplicitStartInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withExplicitStart', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Gets the normalized Bicep identifier for an Azure resource */ - getBicepIdentifier(): Promise { - return this._promise.then(obj => obj.getBicepIdentifier()); + /** Prevents resource from starting automatically */ + withExplicitStart(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withExplicitStartInternal()); } - /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); + /** @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 AzureUserAssignedIdentityResource(result, this._client); } - /** Determines whether a resource is marked as existing */ - isExisting(): Promise { - return this._promise.then(obj => obj.isExisting()); + /** Adds a health check by key */ + withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withHealthCheckInternal(key)); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); + /** @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 ExecuteCommandContext(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 AzureUserAssignedIdentityResource(result, this._client); } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise { + const commandOptions = options?.commandOptions; + return new AzureUserAssignedIdentityResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } - /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); } -} + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParentRelationshipInternal(parent)); + } -// ============================================================================ -// AzureTableStorageResource -// ============================================================================ + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } -export class AzureTableStorageResource extends ResourceBuilderBase { - constructor(handle: AzureTableStorageResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + 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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withContainerRegistryInternal(registry)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise { + const iconVariant = options?.iconVariant; + return new AzureUserAssignedIdentityResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + private async _excludeFromMcpInternal(): 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', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureTableStorageResourcePromise { - const buildImage = options?.buildImage; - const runtimeImage = options?.runtimeImage; - return new AzureTableStorageResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._excludeFromMcpInternal()); } /** @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', + 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 PipelineStepContext(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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureTableStorageResourcePromise { - const helpLink = options?.helpLink; - return new AzureTableStorageResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Adds a pipeline step to the resource */ + 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 AzureUserAssignedIdentityResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionProperty', + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withConnectionPropertyInternal(name, value)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withConnectionPropertyValueInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withConnectionPropertyValue', + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withConnectionPropertyValueInternal(name, value)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + async getResourceName(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResourceName', + rpcArgs + ); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; - const obj = new ResourceUrlsCallbackContext(objHandle, this._client); - await callback(obj); + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallback', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withUrlsCallbackInternal(callback)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; - const arg = new ResourceUrlsCallbackContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withUrlsCallbackAsync', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/onResourceStopped', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, 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', + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureTableStorageResourcePromise { - const displayText = options?.displayText; - return new AzureTableStorageResourcePromise(this._withUrlInternal(url, displayText)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withUrlExpressionInternal(url: 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/withUrlExpression', + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureTableStorageResourcePromise { - const displayText = options?.displayText; - return new AzureTableStorageResourcePromise(this._withUrlExpressionInternal(url, displayText)); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); } /** @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', + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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 _excludeFromManifestInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromManifest', + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._excludeFromManifestInternal()); + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterInternal(name)); } /** @internal */ - private async _withExplicitStartInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withExplicitStart', + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withExplicitStartInternal()); + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterStringValueInternal(name, value)); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { - const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHealthCheck', + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a health check by key */ - withHealthCheck(key: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withHealthCheckInternal(key)); + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterStringValuesInternal(name, value)); } /** @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 ExecuteCommandContext(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', + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureTableStorageResourcePromise { - const commandOptions = options?.commandOptions; - return new AzureTableStorageResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromParameterInternal(name, value)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withParentRelationshipInternal(parent)); + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromOutputInternal(name, value)); } /** @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', + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureTableStorageResourcePromise { - const iconVariant = options?.iconVariant; - return new AzureTableStorageResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._excludeFromMcpInternal()); + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromEndpointInternal(name, value)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._configureInfrastructureInternal(configure)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._publishAsConnectionStringInternal()); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + async getBicepIdentifier(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getBicepIdentifier', + rpcArgs + ); } /** @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 PipelineStepContext(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', + private async _clearDefaultRoleAssignmentsInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureTableStorageResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new AzureTableStorageResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._clearDefaultRoleAssignmentsInternal()); } - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + /** Determines whether a resource is marked as existing */ + async isExisting(): Promise { + const rpcArgs: Record = { resource: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/isExisting', rpcArgs ); - return new AzureTableStorageResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureTableStorageResource(result, this._client); + return new AzureUserAssignedIdentityResource(result, this._client); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromise(this._asExistingInternal(name, resourceGroup)); } } /** - * Thenable wrapper for AzureTableStorageResource that enables fluent chaining. + * Thenable wrapper for AzureUserAssignedIdentityResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureTableStorageResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureUserAssignedIdentityResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureTableStorageResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureUserAssignedIdentityResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); - } - - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); - } - - /** Adds a connection property with a string value */ - withConnectionPropertyValue(name: string, value: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -13664,213 +23241,318 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureTableStorageResourcePromise { - return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + + /** Publishes an Azure resource to the manifest as a connection string */ + publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + + /** Gets the normalized Bicep identifier for an Azure resource */ + getBicepIdentifier(): Promise { + return this._promise.then(obj => obj.getBicepIdentifier()); + } + + /** Clears the default Azure role assignments from a resource */ + clearDefaultRoleAssignments(): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); + } + + /** Determines whether a resource is marked as existing */ + isExisting(): Promise { + return this._promise.then(obj => obj.isExisting()); + } + + /** Marks an Azure resource as existing in run mode */ + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in publish mode */ + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); + } + + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } // ============================================================================ -// AzureUserAssignedIdentityResource +// AzureVirtualNetworkResource // ============================================================================ -export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - constructor(handle: AzureUserAssignedIdentityResourceHandle, client: AspireClientRpc) { +export class AzureVirtualNetworkResource extends ResourceBuilderBase { + constructor(handle: AzureVirtualNetworkResourceHandle, client: AspireClientRpc) { super(handle, client); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, registry }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withContainerRegistry', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withContainerRegistryInternal(registry)); + withContainerRegistry(registry: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withContainerRegistryInternal(registry)); } /** @internal */ - private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withDockerfileBaseImage', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise { + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureVirtualNetworkResourcePromise { const buildImage = options?.buildImage; const runtimeImage = options?.runtimeImage; - return new AzureUserAssignedIdentityResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); + return new AzureVirtualNetworkResourcePromise(this._withDockerfileBaseImageInternal(buildImage, runtimeImage)); } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withRequiredCommand', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise { + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureVirtualNetworkResourcePromise { const helpLink = options?.helpLink; - return new AzureUserAssignedIdentityResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + return new AzureVirtualNetworkResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as ResourceUrlsCallbackContextHandle; const obj = new ResourceUrlsCallbackContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallback', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withUrlsCallbackInternal(callback)); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withUrlsCallbackInternal(callback)); } /** @internal */ - private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { + private async _withUrlsCallbackAsyncInternal(callback: (arg: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as ResourceUrlsCallbackContextHandle; const arg = new ResourceUrlsCallbackContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlsCallbackAsync', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withUrlsCallbackAsyncInternal(callback)); } /** @internal */ - private async _withUrlInternal(url: string, displayText?: string): Promise { + private async _withUrlInternal(url: string, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrl', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise { + withUrl(url: string, options?: WithUrlOptions): AzureVirtualNetworkResourcePromise { const displayText = options?.displayText; - return new AzureUserAssignedIdentityResourcePromise(this._withUrlInternal(url, displayText)); + return new AzureVirtualNetworkResourcePromise(this._withUrlInternal(url, displayText)); } /** @internal */ - private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { + private async _withUrlExpressionInternal(url: ReferenceExpression, displayText?: string): Promise { const rpcArgs: Record = { builder: this._handle, url }; if (displayText !== undefined) rpcArgs.displayText = displayText; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlExpression', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureUserAssignedIdentityResourcePromise { + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureVirtualNetworkResourcePromise { const displayText = options?.displayText; - return new AzureUserAssignedIdentityResourcePromise(this._withUrlExpressionInternal(url, displayText)); + return new AzureVirtualNetworkResourcePromise(this._withUrlExpressionInternal(url, displayText)); } /** @internal */ - private async _withUrlForEndpointInternal(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withUrlForEndpoint', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withUrlForEndpointInternal(endpointName, callback)); } /** @internal */ - private async _excludeFromManifestInternal(): Promise { + private async _excludeFromManifestInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromManifest', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._excludeFromManifestInternal()); + excludeFromManifest(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._excludeFromManifestInternal()); } /** @internal */ - private async _withExplicitStartInternal(): Promise { + private async _withExplicitStartInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withExplicitStart', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withExplicitStartInternal()); + withExplicitStart(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withExplicitStartInternal()); } /** @internal */ - private async _withHealthCheckInternal(key: string): Promise { + private async _withHealthCheckInternal(key: string): Promise { const rpcArgs: Record = { builder: this._handle, key }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withHealthCheck', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withHealthCheckInternal(key)); + withHealthCheck(key: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withHealthCheckInternal(key)); } /** @internal */ - private async _withCommandInternal(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, commandOptions?: CommandOptions): Promise { + 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 ExecuteCommandContext(argHandle, this._client); @@ -13878,113 +23560,98 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase = { builder: this._handle, name, displayName, executeCommand: executeCommandId }; if (commandOptions !== undefined) rpcArgs.commandOptions = commandOptions; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withCommand', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise { + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureVirtualNetworkResourcePromise { const commandOptions = options?.commandOptions; - return new AzureUserAssignedIdentityResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); + return new AzureVirtualNetworkResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureVirtualNetworkResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParentRelationshipInternal(parent)); + withParentRelationship(parent: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withChildRelationshipInternal(child)); + withChildRelationship(child: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { + 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( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withIconName', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise { + withIconName(iconName: string, options?: WithIconNameOptions): AzureVirtualNetworkResourcePromise { const iconVariant = options?.iconVariant; - return new AzureUserAssignedIdentityResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + return new AzureVirtualNetworkResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { + private async _excludeFromMcpInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/excludeFromMcp', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._excludeFromMcpInternal()); - } - - /** @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 AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + excludeFromMcp(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + 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 PipelineStepContext(argHandle, this._client); @@ -13995,60 +23662,60 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureVirtualNetworkResourcePromise { const dependsOn = options?.dependsOn; const requiredBy = options?.requiredBy; const tags = options?.tags; const description = options?.description; - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + return new AzureVirtualNetworkResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; const arg = new PipelineConfigurationContext(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfigurationAsync', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; const obj = new PipelineConfigurationContext(objHandle, this._client); await callback(obj); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting/withPipelineConfiguration', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withPipelineConfigurationInternal(callback)); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withPipelineConfigurationInternal(callback)); } /** Gets the resource name */ @@ -14061,18 +23728,115 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureVirtualNetworkResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureVirtualNetworkResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureVirtualNetworkResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureVirtualNetworkResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _addSubnetInternal(name: string, addressPrefix: string, subnetName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, addressPrefix }; + if (subnetName !== undefined) rpcArgs.subnetName = subnetName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/addSubnet', + rpcArgs + ); + return new AzureSubnetResource(result, this._client); + } + + /** Adds an Azure subnet resource to an Azure Virtual Network resource. */ + addSubnet(name: string, addressPrefix: string, options?: AddSubnetOptions): AzureSubnetResourcePromise { + const subnetName = options?.subnetName; + return new AzureSubnetResourcePromise(this._addSubnetInternal(name, addressPrefix, subnetName)); + } + + /** @internal */ + private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure.Storage/withStorageRoleAssignments', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withStorageRoleAssignmentsInternal(target, roles)); } /** Gets an output reference from an Azure Bicep template resource */ @@ -14085,158 +23849,158 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + private async _withParameterInternal(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameter', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter without a value */ - withParameter(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterInternal(name)); + withParameter(name: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterInternal(name)); } /** @internal */ - private async _withParameterStringValueInternal(name: string, value: string): Promise { + private async _withParameterStringValueInternal(name: string, value: string): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameterStringValue', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterStringValueInternal(name, value)); + withParameterStringValue(name: string, value: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterStringValueInternal(name, value)); } /** @internal */ - private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameterStringValues', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterStringValuesInternal(name, value)); + withParameterStringValues(name: string, value: string[]): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterStringValuesInternal(name, value)); } /** @internal */ - private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameterFromParameter', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromParameterInternal(name, value)); + withParameterFromParameter(name: string, value: ParameterResource): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterFromParameterInternal(name, value)); } /** @internal */ - private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameterFromConnectionString', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); } /** @internal */ - private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameterFromOutput', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromOutputInternal(name, value)); + withParameterFromOutput(name: string, value: BicepOutputReference): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterFromOutputInternal(name, value)); } /** @internal */ - private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); } /** @internal */ - private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/withParameterFromEndpoint', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withParameterFromEndpointInternal(name, value)); + withParameterFromEndpoint(name: string, value: EndpointReference): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._withParameterFromEndpointInternal(name, value)); } /** @internal */ - private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { + private async _configureInfrastructureInternal(configure: (obj: AzureResourceInfrastructure) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; const obj = new AzureResourceInfrastructure(objHandle, this._client); await configure(obj); }); const rpcArgs: Record = { builder: this._handle, configure: configureId }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/configureInfrastructure', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Configures the Azure provisioning infrastructure callback */ - configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._configureInfrastructureInternal(configure)); + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._configureInfrastructureInternal(configure)); } /** @internal */ - private async _publishAsConnectionStringInternal(): Promise { + private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsConnectionString', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsConnectionStringInternal()); + publishAsConnectionString(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._publishAsConnectionStringInternal()); } /** Gets the normalized Bicep identifier for an Azure resource */ @@ -14249,18 +24013,18 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + private async _clearDefaultRoleAssignmentsInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( + const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/clearDefaultRoleAssignments', rpcArgs ); - return new AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Clears the default Azure role assignments from a resource */ - clearDefaultRoleAssignments(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._clearDefaultRoleAssignmentsInternal()); + clearDefaultRoleAssignments(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._clearDefaultRoleAssignmentsInternal()); } /** Determines whether a resource is marked as existing */ @@ -14273,200 +24037,171 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingInternal(name, resourceGroup)); - } - - /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureVirtualNetworkResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureVirtualNetworkResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; - const result = await this._client.invokeCapability( + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureVirtualNetworkResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureVirtualNetworkResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + 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 AzureUserAssignedIdentityResource(result, this._client); + return new AzureVirtualNetworkResource(result, this._client); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureVirtualNetworkResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureVirtualNetworkResourcePromise(this._asExistingInternal(name, resourceGroup)); } } /** - * Thenable wrapper for AzureUserAssignedIdentityResource that enables fluent chaining. + * Thenable wrapper for AzureVirtualNetworkResource that enables fluent chaining. * @example * await builder.addSomething().withX().withY(); */ -export class AzureUserAssignedIdentityResourcePromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class AzureVirtualNetworkResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: AzureUserAssignedIdentityResource) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: AzureVirtualNetworkResource) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); + withContainerRegistry(registry: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } /** Sets the base image for a Dockerfile build */ - withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); + withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); } /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); } /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + withUrl(url: string, options?: WithUrlOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); } /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); } /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); } /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + excludeFromManifest(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); } /** Prevents resource from starting automatically */ - withExplicitStart(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + withExplicitStart(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withExplicitStart())); } /** Adds a health check by key */ - withHealthCheck(key: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + withHealthCheck(key: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); } /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); } /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + withParentRelationship(parent: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); } /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + withChildRelationship(child: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); } /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + withIconName(iconName: string, options?: WithIconNameOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); } /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + excludeFromMcp(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); } /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); } /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } /** Gets the resource name */ @@ -14474,9 +24209,34 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Adds an Azure subnet resource to an Azure Virtual Network resource. */ + addSubnet(name: string, addressPrefix: string, options?: AddSubnetOptions): AzureSubnetResourcePromise { + return new AzureSubnetResourcePromise(this._promise.then(obj => obj.addSubnet(name, addressPrefix, options))); + } + /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); } /** Gets an output reference from an Azure Bicep template resource */ @@ -14485,53 +24245,53 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.withParameter(name))); + withParameter(name: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameter(name))); } /** Adds a Bicep parameter with a string value */ - withParameterStringValue(name: string, value: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + withParameterStringValue(name: string, value: string): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); } /** Adds a Bicep parameter with a string list value */ - withParameterStringValues(name: string, value: string[]): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + withParameterStringValues(name: string, value: string[]): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); } /** Adds a Bicep parameter from a parameter resource builder */ - withParameterFromParameter(name: string, value: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + withParameterFromParameter(name: string, value: ParameterResource): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); } /** Adds a Bicep parameter from a connection string resource builder */ - withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); } /** Adds a Bicep parameter from another Bicep output reference */ - withParameterFromOutput(name: string, value: BicepOutputReference): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + withParameterFromOutput(name: string, value: BicepOutputReference): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); } /** Adds a Bicep parameter from a reference expression */ - withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); } /** Adds a Bicep parameter from an endpoint reference */ - withParameterFromEndpoint(name: string, value: EndpointReference): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + withParameterFromEndpoint(name: string, value: EndpointReference): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); } /** Configures the Azure provisioning infrastructure callback */ - configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); } /** Publishes an Azure resource to the manifest as a connection string */ - publishAsConnectionString(): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + publishAsConnectionString(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); } /** Gets the normalized Bicep identifier for an Azure resource */ @@ -14540,8 +24300,8 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.clearDefaultRoleAssignments())); + clearDefaultRoleAssignments(): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.clearDefaultRoleAssignments())); } /** Determines whether a resource is marked as existing */ @@ -14549,29 +24309,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureVirtualNetworkResourcePromise { + return new AzureVirtualNetworkResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -14637,7 +24387,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -14646,8 +24396,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -14778,7 +24537,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -14808,7 +24567,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -14854,7 +24613,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -14903,11 +24662,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -14922,7 +24696,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -14965,36 +24739,6 @@ export class ConnectionStringResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ConnectionStringResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -15072,6 +24816,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -15119,8 +24963,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -15129,6 +24973,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -15199,6 +25048,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15219,16 +25073,6 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -15249,6 +25093,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -15477,95 +25346,80 @@ export class ContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ - private async _withIconNameInternal(iconName: string, iconVariant?: IconVariant): Promise { - const rpcArgs: Record = { builder: this._handle, iconName }; - if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withIconName', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - const iconVariant = options?.iconVariant; - return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withParentRelationshipInternal(parent)); } /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withChildRelationshipInternal(child)); } /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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/withRemoteImageName', + 'Aspire.Hosting/withIconName', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + const iconVariant = options?.iconVariant; + return new ContainerRegistryResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new ContainerRegistryResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ @@ -15645,6 +25499,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -15692,130 +25626,399 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Customizes displayed URLs via callback */ - withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + /** Customizes displayed URLs via callback */ + withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); + } + + /** Customizes displayed URLs via async callback */ + withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + } + + /** Adds or modifies displayed URLs */ + withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + } + + /** Adds a URL using a reference expression */ + withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + } + + /** Customizes the URL for a specific endpoint via callback */ + withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + } + + /** Excludes the resource from the deployment manifest */ + excludeFromManifest(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + } + + /** Prevents resource from starting automatically */ + withExplicitStart(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + } + + /** Adds a health check by key */ + withHealthCheck(key: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + } + + /** Adds a resource command */ + withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + } + + /** Adds a pipeline step to the resource */ + withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + } + + /** Gets the resource name */ + getResourceName(): Promise { + return this._promise.then(obj => obj.getResourceName()); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Assigns Azure Storage roles to a resource */ + withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + } + +} + +// ============================================================================ +// ContainerResource +// ============================================================================ + +export class ContainerResource extends ResourceBuilderBase { + constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, registry }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerRegistry', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures a resource to use a container registry */ + withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageTagInternal(tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromise(this._withImageInternal(image, tag)); } - /** Customizes displayed URLs via async callback */ - withUrlsCallbackAsync(callback: (arg: ResourceUrlsCallbackContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlsCallbackAsync(callback))); + /** @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 ContainerResource(result, this._client); } - /** Adds or modifies displayed URLs */ - withUrl(url: string, options?: WithUrlOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrl(url, options))); + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageSHA256Internal(sha256)); } - /** Adds a URL using a reference expression */ - withUrlExpression(url: ReferenceExpression, options?: WithUrlExpressionOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlExpression(url, options))); + /** @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 ContainerResource(result, this._client); } - /** Customizes the URL for a specific endpoint via callback */ - withUrlForEndpoint(endpointName: string, callback: (obj: ResourceUrlAnnotation) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withUrlForEndpoint(endpointName, callback))); + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); } - /** Excludes the resource from the deployment manifest */ - excludeFromManifest(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromManifest())); + /** @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 ContainerResource(result, this._client); } - /** Prevents resource from starting automatically */ - withExplicitStart(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withExplicitStart())); + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._withLifetimeInternal(lifetime)); } - /** Adds a health check by key */ - withHealthCheck(key: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withHealthCheck(key))); + /** @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 ContainerResource(result, this._client); } - /** Adds a resource command */ - withCommand(name: string, displayName: string, executeCommand: (arg: ExecuteCommandContext) => Promise, options?: WithCommandOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); } - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withChildRelationship(child))); + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsContainerInternal()); } - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withIconName(iconName, options))); + /** @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 ContainerResource(result, this._client); } - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + /** @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 ContainerResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNameInternal(name)); } - /** Adds a pipeline step to the resource */ - withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfigurationAsync(callback))); + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResource(result, this._client); } - /** Gets the resource name */ - getResourceName(): Promise { - return this._promise.then(obj => obj.getResourceName()); + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); } - /** Assigns Azure Storage roles to a resource */ - withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); + /** @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 ContainerResource(result, this._client); } -} - -// ============================================================================ -// ContainerResource -// ============================================================================ - -export class ContainerResource extends ResourceBuilderBase { - constructor(handle: ContainerResourceHandle, client: AspireClientRpc) { - super(handle, client); + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); } /** @internal */ - private async _withContainerRegistryInternal(registry: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, registry }; + private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, proxyEnabled }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withContainerRegistry', + 'Aspire.Hosting/withEndpointProxySupport', rpcArgs ); return new ContainerResource(result, this._client); } - /** Configures a resource to use a container registry */ - withContainerRegistry(registry: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withContainerRegistryInternal(registry)); + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); } /** @internal */ @@ -15837,6 +26040,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -15887,58 +26105,43 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -15949,43 +26152,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -16074,52 +26272,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -16419,7 +26604,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -16449,7 +26634,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -16495,7 +26680,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -16600,7 +26785,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -16627,11 +26812,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -16646,7 +26846,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -16816,6 +27016,25 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -16825,6 +27044,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -16874,7 +27193,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ContainerResource(result, this._client); @@ -16907,11 +27226,96 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRegistry(registry))); } + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -16927,36 +27331,31 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -16982,21 +27381,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -17142,6 +27536,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -17192,11 +27591,41 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -17342,58 +27771,50 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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 CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironment', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -17404,43 +27825,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -17529,52 +27945,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -17859,7 +28262,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -17889,7 +28292,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -17919,7 +28322,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -17965,7 +28368,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -18070,7 +28473,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -18097,11 +28500,26 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -18116,7 +28534,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -18295,6 +28713,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -18344,7 +28862,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -18407,36 +28925,31 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -18462,21 +28975,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -18627,6 +29135,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18682,6 +29195,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -18969,41 +29507,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -19014,43 +29522,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -19139,52 +29642,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -19484,7 +29974,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -19514,7 +30004,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -19560,7 +30050,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -19665,7 +30155,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -19692,11 +30182,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -19711,7 +30216,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -19876,18 +30381,118 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -19939,7 +30544,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -20047,31 +30652,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -20097,21 +30692,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -20257,6 +30847,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -20312,6 +30907,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -20377,6 +30997,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -20444,41 +31129,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -20489,43 +31144,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -20614,52 +31264,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -20959,7 +31596,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -20989,7 +31626,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -21035,7 +31672,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -21140,7 +31777,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -21167,11 +31804,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -21186,7 +31838,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -21317,52 +31969,152 @@ export class ExecutableResource extends ResourceBuilderBase Promise): Promise { + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -21414,7 +32166,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ExecutableResource(result, this._client); @@ -21452,6 +32204,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -21472,31 +32244,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -21522,21 +32284,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -21682,6 +32439,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -21737,6 +32499,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -21998,11 +32785,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -22017,7 +32819,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -22060,36 +32862,6 @@ export class ExternalServiceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ExternalServiceResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -22167,6 +32939,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -22264,6 +33116,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -22284,16 +33141,6 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -22314,6 +33161,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -22558,11 +33425,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -22577,7 +33459,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -22621,110 +33503,160 @@ export class ParameterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + 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 PipelineStepContext(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/withRemoteImageName', + 'Aspire.Hosting/withPipelineStepFactory', rpcArgs ); return new ParameterResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Adds a pipeline step to the resource */ + 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 ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ParameterResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/onBeforeResourceStarted', rpcArgs ); return new ParameterResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onResourceStopped', rpcArgs ); return new ParameterResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 ParameterResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ParameterResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ParameterResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ParameterResourcePromise { - return new ParameterResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -22824,6 +33756,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -22844,16 +33781,6 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -22874,6 +33801,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -22974,74 +33921,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -23049,15 +33998,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -23075,6 +34024,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -23161,52 +34125,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -23491,7 +34442,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -23521,7 +34472,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -23551,7 +34502,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -23597,7 +34548,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -23702,7 +34653,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -23729,11 +34680,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -23748,7 +34714,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -23851,80 +34817,180 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withPipelineStepFactoryInternal(stepName: string, callback: (arg: PipelineStepContext) => Promise, dependsOn?: string[], requiredBy?: string[], tags?: string[], description?: string): Promise { + 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 PipelineStepContext(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 ProjectResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + 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 ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ProjectResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineStepContextHandle; - const arg = new PipelineStepContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineStepFactory', + 'Aspire.Hosting/onInitializeResource', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a pipeline step to the resource */ - 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 ProjectResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ProjectResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -23976,7 +35042,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ProjectResource(result, this._client); @@ -24029,29 +35095,29 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -24059,6 +35125,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -24084,21 +35155,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -24249,6 +35315,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -24304,6 +35375,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -24448,7 +35544,7 @@ export class SqlServerDatabaseResource extends ResourceBuilderBase { + 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', @@ -24457,8 +35553,8 @@ export class SqlServerDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -24637,11 +35742,26 @@ export class SqlServerDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new SqlServerDatabaseResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new SqlServerDatabaseResource(result, this._client); @@ -24656,7 +35776,7 @@ export class SqlServerDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new SqlServerDatabaseResource(result, this._client); @@ -24699,36 +35819,6 @@ export class SqlServerDatabaseResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new SqlServerDatabaseResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 SqlServerDatabaseResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -24806,6 +35896,106 @@ export class SqlServerDatabaseResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 SqlServerDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -24868,8 +36058,8 @@ export class SqlServerDatabaseResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): SqlServerDatabaseResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): SqlServerDatabaseResourcePromise { return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -24878,6 +36068,11 @@ export class SqlServerDatabaseResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): SqlServerDatabaseResourcePromise { return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -24923,6 +36118,11 @@ export class SqlServerDatabaseResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): SqlServerDatabaseResourcePromise { return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -24943,16 +36143,6 @@ export class SqlServerDatabaseResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): SqlServerDatabaseResourcePromise { - return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): SqlServerDatabaseResourcePromise { return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -24973,6 +36163,31 @@ export class SqlServerDatabaseResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): SqlServerDatabaseResourcePromise { + return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): SqlServerDatabaseResourcePromise { return new SqlServerDatabaseResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -25027,6 +36242,17 @@ export class SqlServerServerResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/SqlServerServerResource.passwordParameter', + { context: this._handle } + ); + return new ParameterResource(handle, this._client); + }, + }; + /** Gets the UserNameReference property */ userNameReference = { get: async (): Promise => { @@ -25327,7 +36553,7 @@ export class SqlServerServerResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -25336,8 +36562,8 @@ export class SqlServerServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -25356,6 +36582,27 @@ export class SqlServerServerResource extends ResourceBuilderBase { + 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 SqlServerServerResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): SqlServerServerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new SqlServerServerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -25482,62 +36729,12 @@ export class SqlServerServerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', - rpcArgs - ); - return new SqlServerServerResource(result, this._client); - } - - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + const helpLink = options?.helpLink; + return new SqlServerServerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -25545,15 +36742,15 @@ export class SqlServerServerResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new SqlServerServerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -25571,6 +36768,21 @@ export class SqlServerServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -25602,7 +36814,7 @@ export class SqlServerServerResource extends ResourceBuilderBase { + 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', @@ -25611,8 +36823,8 @@ export class SqlServerServerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new SqlServerServerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): SqlServerServerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new SqlServerServerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', + 'Aspire.Hosting/withReference', rpcArgs ); return new SqlServerServerResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withServiceReferenceInternal(source)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): SqlServerServerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new SqlServerServerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', rpcArgs ); - return new SqlServerServerResource(result, this._client); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); } /** @internal */ @@ -26032,7 +37240,7 @@ export class SqlServerServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -26062,7 +37270,7 @@ export class SqlServerServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -26108,7 +37316,7 @@ export class SqlServerServerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -26213,7 +37421,7 @@ export class SqlServerServerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -26240,11 +37448,26 @@ export class SqlServerServerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new SqlServerServerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -26259,7 +37482,7 @@ export class SqlServerServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -26457,6 +37680,126 @@ export class SqlServerServerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 SqlServerServerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -26506,7 +37849,7 @@ export class SqlServerServerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new SqlServerServerResource(result, this._client); @@ -26684,8 +38027,8 @@ export class SqlServerServerResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): SqlServerServerResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -26694,6 +38037,11 @@ export class SqlServerServerResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -26734,31 +38082,21 @@ export class SqlServerServerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -26769,8 +38107,8 @@ export class SqlServerServerResourcePromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): SqlServerServerResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -26794,19 +38132,19 @@ export class SqlServerServerResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): SqlServerServerResourcePromise { - return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Adds a reference to a URI */ @@ -26954,6 +38292,11 @@ export class SqlServerServerResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -27014,6 +38357,36 @@ export class SqlServerServerResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): SqlServerServerResourcePromise { + return new SqlServerServerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): SqlServerServerResourcePromise { return new SqlServerServerResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -27061,6 +38434,82 @@ export class SqlServerServerResourcePromise implements PromiseLike { + constructor(handle: IAzureDelegatedSubnetResourceHandle, client: AspireClientRpc) { + super(handle, client); + } + + /** @internal */ + private async _withDelegatedSubnetInternal(subnet: AzureSubnetResource): Promise { + const rpcArgs: Record = { builder: this._handle, subnet }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Network/withSubnetDelegatedSubnet', + rpcArgs + ); + return new AzureDelegatedSubnetResource(result, this._client); + } + + /** Associates a delegated Azure subnet resource with an Azure resource that supports subnet delegation. */ + withDelegatedSubnet(subnet: AzureSubnetResource): AzureDelegatedSubnetResourcePromise { + return new AzureDelegatedSubnetResourcePromise(this._withDelegatedSubnetInternal(subnet)); + } + +} + +/** + * Thenable wrapper for AzureDelegatedSubnetResource that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzureDelegatedSubnetResourcePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzureDelegatedSubnetResource) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Associates a delegated Azure subnet resource with an Azure resource that supports subnet delegation. */ + withDelegatedSubnet(subnet: AzureSubnetResource): AzureDelegatedSubnetResourcePromise { + return new AzureDelegatedSubnetResourcePromise(this._promise.then(obj => obj.withDelegatedSubnet(subnet))); + } + +} + +// ============================================================================ +// AzurePrivateEndpointTarget +// ============================================================================ + +export class AzurePrivateEndpointTarget extends ResourceBuilderBase { + constructor(handle: IAzurePrivateEndpointTargetHandle, client: AspireClientRpc) { + super(handle, client); + } + +} + +/** + * Thenable wrapper for AzurePrivateEndpointTarget that enables fluent chaining. + * @example + * await builder.addSomething().withX().withY(); + */ +export class AzurePrivateEndpointTargetPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: AzurePrivateEndpointTarget) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + +} + // ============================================================================ // AzureResource // ============================================================================ @@ -27119,23 +38568,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -27144,28 +38579,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -27174,13 +38596,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -27189,8 +38613,9 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -27230,29 +38655,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -27266,11 +38681,41 @@ export class ComputeResource extends ResourceBuilderBase super(handle, 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 ComputeResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ComputeResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + /** @internal */ private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ComputeResource(result, this._client); @@ -27298,6 +38743,16 @@ export class ComputeResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + /** Associates an Azure user-assigned identity with a compute resource */ withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): ComputeResourcePromise { return new ComputeResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); @@ -27318,7 +38773,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -27573,11 +39028,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -27592,7 +39062,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -27635,36 +39105,6 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._excludeFromMcpInternal()); } - /** @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 Resource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 Resource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -27742,6 +39182,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withStorageRoleAssignmentsInternal(target: AzureStorageResource, roles: AzureStorageRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -27834,6 +39354,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -27854,16 +39379,6 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -27884,6 +39399,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Azure Storage roles to a resource */ withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withStorageRoleAssignments(target, roles))); @@ -27999,7 +39534,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -28008,8 +39543,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -28045,8 +39609,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -28055,6 +39619,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -28343,6 +39917,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -28410,6 +40004,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -28452,41 +40051,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -28497,43 +40066,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -28567,52 +40131,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -28695,7 +40246,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -28779,31 +40330,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -28814,21 +40355,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -28876,34 +40412,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -28917,7 +40425,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -28947,7 +40455,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -28978,7 +40486,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -29097,7 +40605,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { const error = reason instanceof Error ? reason : new Error(String(reason)); - if (reason instanceof CapabilityError) { + 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) { @@ -29128,8 +40638,12 @@ process.on('unhandledRejection', (reason: unknown) => { }); process.on('uncaughtException', (error: Error) => { - console.error(`\n❌ Uncaught Exception: ${error.message}`); - if (error.stack) { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + if (!(error instanceof AppHostUsageError) && error.stack) { console.error(error.stack); } process.exit(1); @@ -29140,38 +40654,67 @@ process.on('uncaughtException', (error: Error) => { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureBlobStorageContainerResource', (handle, client) => new AzureBlobStorageContainerResource(handle as AzureBlobStorageContainerResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureBlobStorageResource', (handle, client) => new AzureBlobStorageResource(handle as AzureBlobStorageResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureDataLakeStorageFileSystemResource', (handle, client) => new AzureDataLakeStorageFileSystemResource(handle as AzureDataLakeStorageFileSystemResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureDataLakeStorageResource', (handle, client) => new AzureDataLakeStorageResource(handle as AzureDataLakeStorageResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource', (handle, client) => new AzureEnvironmentResource(handle as AzureEnvironmentResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureNatGatewayResource', (handle, client) => new AzureNatGatewayResource(handle as AzureNatGatewayResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureNetworkSecurityGroupResource', (handle, client) => new AzureNetworkSecurityGroupResource(handle as AzureNetworkSecurityGroupResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzurePrivateEndpointResource', (handle, client) => new AzurePrivateEndpointResource(handle as AzurePrivateEndpointResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureProvisioningResource', (handle, client) => new AzureProvisioningResource(handle as AzureProvisioningResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzurePublicIPAddressResource', (handle, client) => new AzurePublicIPAddressResource(handle as AzurePublicIPAddressResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureQueueStorageQueueResource', (handle, client) => new AzureQueueStorageQueueResource(handle as AzureQueueStorageQueueResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureQueueStorageResource', (handle, client) => new AzureQueueStorageResource(handle as AzureQueueStorageResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.AzureSqlDatabaseResource', (handle, client) => new AzureSqlDatabaseResource(handle as AzureSqlDatabaseResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.AzureSqlServerResource', (handle, client) => new AzureSqlServerResource(handle as AzureSqlServerResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureStorageEmulatorResource', (handle, client) => new AzureStorageEmulatorResource(handle as AzureStorageEmulatorResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureStorageResource', (handle, client) => new AzureStorageResource(handle as AzureStorageResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureSubnetResource', (handle, client) => new AzureSubnetResource(handle as AzureSubnetResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureTableStorageResource', (handle, client) => new AzureTableStorageResource(handle as AzureTableStorageResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureUserAssignedIdentityResource', (handle, client) => new AzureUserAssignedIdentityResource(handle as AzureUserAssignedIdentityResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.AzureVirtualNetworkResource', (handle, client) => new AzureVirtualNetworkResource(handle as AzureVirtualNetworkResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ConnectionStringResource', (handle, client) => new ConnectionStringResource(handle as ConnectionStringResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource', (handle, client) => new ContainerRegistryResource(handle as ContainerRegistryResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource', (handle, client) => new ContainerResource(handle as ContainerResourceHandle, client)); @@ -29183,6 +40726,8 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ParameterR registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource', (handle, client) => new ProjectResource(handle as ProjectResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerDatabaseResource', (handle, client) => new SqlServerDatabaseResource(handle as SqlServerDatabaseResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.SqlServer/Aspire.Hosting.ApplicationModel.SqlServerServerResource', (handle, client) => new SqlServerServerResource(handle as SqlServerServerResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureDelegatedSubnetResource', (handle, client) => new AzureDelegatedSubnetResource(handle as IAzureDelegatedSubnetResourceHandle, client)); +registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzurePrivateEndpointTarget', (handle, client) => new AzurePrivateEndpointTarget(handle as IAzurePrivateEndpointTargetHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.ApplicationModel.IAzureResource', (handle, client) => new AzureResource(handle as IAzureResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IComputeResource', (handle, client) => new ComputeResource(handle as IComputeResourceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource', (handle, client) => new ContainerFilesDestinationResource(handle as IContainerFilesDestinationResourceHandle, client)); @@ -29192,6 +40737,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/base.ts index 7778b0f1737..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -43,22 +43,46 @@ export class ReferenceExpression { private readonly _format?: string; private readonly _valueProviders?: unknown[]; + // Conditional mode fields + private readonly _condition?: unknown; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; + private readonly _matchValue?: string; + // Handle mode fields (when wrapping a server-returned handle) private readonly _handle?: Handle; private readonly _client?: AspireClient; constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(handleOrFormat: Handle | string, clientOrValueProviders: AspireClient | unknown[]) { - if (typeof handleOrFormat === 'string') { - this._format = handleOrFormat; - this._valueProviders = clientOrValueProviders as unknown[]; + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression + ) { + if (typeof handleOrFormatOrCondition === 'string') { + this._format = handleOrFormatOrCondition; + this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (handleOrFormatOrCondition instanceof Handle) { + this._handle = handleOrFormatOrCondition; + this._client = clientOrValueProvidersOrMatchValue as AspireClient; } else { - this._handle = handleOrFormat; - this._client = clientOrValueProviders as AspireClient; + this._condition = handleOrFormatOrCondition; + this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + this._whenTrue = whenTrueOrWhenFalse; + this._whenFalse = whenFalse; } } + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return this._condition !== undefined; + } + /** * Creates a reference expression from a tagged template literal. * @@ -82,16 +106,46 @@ export class ReferenceExpression { return new ReferenceExpression(format, valueProviders); } + /** + * Creates a conditional reference expression from its constituent parts. + * + * @param condition - A value provider whose result is compared to matchValue + * @param whenTrue - The expression to use when the condition matches + * @param whenFalse - The expression to use when the condition does not match + * @param matchValue - The value to compare the condition against (defaults to "True") + * @returns A ReferenceExpression instance in conditional mode + */ + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression { + return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + } + /** * Serializes the reference expression for JSON-RPC transport. - * In template-literal mode, uses the $expr format. + * 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[] } } | MarshalledHandle { + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { if (this._handle) { return this._handle.toJSON(); } + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(this._condition), + whenTrue: this._whenTrue!.toJSON(), + whenFalse: this._whenFalse!.toJSON(), + matchValue: this._matchValue! + } + }; + } + return { $expr: { format: this._format!, @@ -100,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -107,10 +185,17 @@ export class ReferenceExpression { if (this._handle) { return `ReferenceExpression(handle)`; } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } return `ReferenceExpression(${this._format})`; } } +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. @@ -136,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -307,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -466,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/transport.ts index 7bddd74beff..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -213,6 +354,76 @@ export class CapabilityError extends Error { } } +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + } +} + +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 // ============================================================================ @@ -324,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -346,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -361,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -381,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -411,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -422,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -432,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + 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; - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + let settled = false; - this.socket = net.createConnection(pipePath); + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -475,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -533,39 +935,66 @@ export class AspireClient { throw new Error('Not connected to AppHost'); } - // 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++; + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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++; - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + 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 { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/apphost.ts index 9add6023451..7e1858f6a6a 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/apphost.ts @@ -2,11 +2,14 @@ import { createBuilder } from './.modules/aspire.js'; const builder = await createBuilder(); const storage = await builder.addAzureStorage("storage"); +const vnet = await builder.addAzureVirtualNetwork("vnet"); +const deploymentSubnet = await vnet.addSubnet("deployment-subnet", "10.0.1.0/24"); const sqlServer = await builder.addAzureSqlServer("sql"); const db = await sqlServer.addDatabase("mydb"); const db2 = await sqlServer.addDatabase("inventory", { databaseName: "inventorydb" }); await db2.withDefaultAzureSku(); await sqlServer.runAsContainer({ configureContainer: async _ => {} }); +await sqlServer.withAdminDeploymentScriptSubnet(deploymentSubnet); await sqlServer.withAdminDeploymentScriptStorage(storage); const _db3 = await sqlServer.addDatabase("analytics").withDefaultAzureSku(); @@ -15,9 +18,13 @@ const _port = await sqlServer.port.get(); const _uriExpression = await sqlServer.uriExpression.get(); const _connectionStringExpression = await sqlServer.connectionStringExpression.get(); const _jdbcConnectionString = await sqlServer.jdbcConnectionString.get(); +const _fullyQualifiedDomainName = await sqlServer.fullyQualifiedDomainName.get(); +const _nameOutputReference = await sqlServer.nameOutputReference.get(); +const _resourceId = await sqlServer.id.get(); const _isContainer: boolean = await sqlServer.isContainer.get(); const _databaseCount = await sqlServer.databases.count(); const _hasMyDb: boolean = await sqlServer.databases.containsKey("mydb"); +const _azureSqlDatabase = await sqlServer.azureSqlDatabases.get("mydb"); const _parent = await db.parent.get(); const _dbConnectionStringExpression = await db.connectionStringExpression.get(); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..6f2a751cfd0 --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure.Sql/ValidationAppHost/aspire.config.json @@ -0,0 +1,11 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "packages": { + "Aspire.Hosting.Azure.Network": "", + "Aspire.Hosting.Azure.Sql": "", + "Aspire.Hosting.Azure.Storage": "" + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/.codegen-hash index b7f6957b854..671c98af187 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -D83C31FC4F208C58105CBD52A1D3386D195F398E56034C36677ACB0F2B9C4D21 \ No newline at end of file +ACCA6A865989586F6D47BBC34388D889C4CB4228A12E1775EDFAFAADEACBFC7A \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/aspire.ts index aa4faf93cb4..9d7487cbc49 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/aspire.ts @@ -8,6 +8,8 @@ import { AspireClient as AspireClientRpc, Handle, MarshalledHandle, + AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -50,9 +52,21 @@ type BicepOutputReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Az /** Handle to IAzureKeyVaultSecretReference */ type IAzureKeyVaultSecretReferenceHandle = Handle<'Aspire.Hosting.Azure/Aspire.Hosting.Azure.IAzureKeyVaultSecretReference'>; +/** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -62,6 +76,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -86,6 +103,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -116,15 +136,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -149,18 +181,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -173,12 +220,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -226,6 +279,7 @@ export enum EndpointProperty { Scheme = "Scheme", TargetPort = "TargetPort", HostAndPort = "HostAndPort", + TlsEnabled = "TlsEnabled", } /** Enum type for IconVariant */ @@ -301,6 +355,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -331,6 +391,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -357,7 +438,7 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } -export interface AddContainerRegistry1Options { +export interface AddContainerRegistryFromStringOptions { repository?: string; } @@ -370,16 +451,21 @@ export interface AddDockerfileOptions { stage?: string; } -export interface AddParameter1Options { - publishValueAsDefault?: boolean; +export interface AddParameterFromConfigurationOptions { secret?: boolean; } -export interface AddParameterFromConfigurationOptions { +export interface AddParameterOptions { secret?: boolean; } -export interface AddParameterOptions { +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; secret?: boolean; } @@ -391,18 +477,84 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; +} + +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; } export interface RunOptions { - cancellationToken?: AbortSignal; + 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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithBindMountOptions { isReadOnly?: boolean; } @@ -411,6 +563,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDescriptionOptions { enableMarkdown?: boolean; } @@ -500,6 +658,7 @@ export interface WithPipelineStepFactoryOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -519,6 +678,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -560,6 +756,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -634,11 +904,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -653,6 +924,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -670,9 +1000,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -746,6 +1076,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -768,6 +1109,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -781,6 +1186,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -847,6 +1263,16 @@ export class EndpointReference { }, }; + /** Gets the TlsEnabled property */ + tlsEnabled = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.tlsEnabled', + { context: this._handle } + ); + }, + }; + /** Gets the Port property */ port = { get: async (): Promise => { @@ -901,13 +1327,22 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs ); } + /** Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise. */ + 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 + ); + } + } /** @@ -928,6 +1363,11 @@ export class EndpointReferencePromise implements PromiseLike return this._promise.then(obj => obj.getValueAsync(options)); } + /** 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 { + return this._promise.then(obj => obj.getTlsValue(enabledValue, disabledValue)); + } + } // ============================================================================ @@ -1005,11 +1445,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1039,6 +1502,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1057,16 +1531,17 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', - { context: this._handle, value } + { context: this._handle, value: CancellationToken.fromValue(value) } ); } }; @@ -1074,35 +1549,127 @@ export class ExecuteCommandContext { } // ============================================================================ -// PipelineConfigurationContext +// InitializeResourceEvent // ============================================================================ /** - * Type class for PipelineConfigurationContext. + * Type class for InitializeResourceEvent. */ -export class PipelineConfigurationContext { - constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Steps property */ - steps = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, - set: async (value: PipelineStep[]): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', - { context: this._handle, value } - ); - } }; - /** Gets pipeline steps with the specified tag */ + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineConfigurationContext +// ============================================================================ + +/** + * Type class for PipelineConfigurationContext. + */ +export class PipelineConfigurationContext { + constructor(private _handle: PipelineConfigurationContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Steps property */ + steps = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.steps', + { context: this._handle } + ); + }, + set: async (value: PipelineStep[]): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.setSteps', + { context: this._handle, value } + ); + } + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; return await this._client.invokeCapability( @@ -1133,6 +1700,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1220,6 +1874,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1290,6 +1955,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1301,18 +1999,159 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + +// ============================================================================ +// PipelineStepFactoryContext +// ============================================================================ + +/** + * Type class for PipelineStepFactoryContext. + */ +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; } +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } + +} + // ============================================================================ // ProjectResourceOptions // ============================================================================ @@ -1495,86 +2334,381 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike; - get urls(): AspireList { - if (!this._urls) { - this._urls = new AspireList( - this._handle, - this._client, - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' - ); - } - return this._urls; - } - - /** Gets the CancellationToken property */ - cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, }; - /** Gets the ExecutionContext property */ - executionContext = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', { context: this._handle } ); - return new DistributedApplicationExecutionContext(handle, this._client); + return new ServiceProvider(handle, this._client); }, }; } // ============================================================================ -// DistributedApplicationBuilder +// ResourceLoggerService // ============================================================================ /** - * Type class for DistributedApplicationBuilder. + * Type class for ResourceLoggerService. */ -export class DistributedApplicationBuilder { - constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the AppHostDirectory property */ - appHostDirectory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', - { context: this._handle } - ); - }, + /** Completes the log stream for a resource */ + /** @internal */ + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + } + + /** Completes the log stream by resource name */ + /** @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 ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); + } + + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ + /** @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 ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + } + + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** Waits for all dependencies of a resource to be ready */ + /** @internal */ + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + } + + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ + /** @internal */ + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, }; - /** Gets the Eventing property */ - eventing = { - get: async (): Promise => { - const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', { context: this._handle } ); - return new DistributedApplicationEventing(handle, this._client); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceUrlsCallbackContext +// ============================================================================ + +/** + * Type class for ResourceUrlsCallbackContext. + */ +export class ResourceUrlsCallbackContext { + constructor(private _handle: ResourceUrlsCallbackContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Urls property */ + private _urls?: AspireList; + get urls(): AspireList { + if (!this._urls) { + this._urls = new AspireList( + this._handle, + this._client, + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.urls' + ); + } + return this._urls; + } + + /** Gets the CancellationToken property */ + cancellationToken = { + get: async (): Promise => { + const result = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', + { context: this._handle } + ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); }, }; @@ -1582,634 +2716,1739 @@ export class DistributedApplicationBuilder { executionContext = { get: async (): Promise => { const handle = await this._client.invokeCapability( - 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.executionContext', { context: this._handle } ); return new DistributedApplicationExecutionContext(handle, this._client); }, }; - /** Builds the distributed application */ - /** @internal */ - async _buildInternal(): Promise { - const rpcArgs: Record = { context: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/build', +} + +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', + rpcArgs + ); + } + + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); + } + + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', + rpcArgs + ); + } + + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); + } + + /** Checks whether a configuration section exists */ + 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. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + +// ============================================================================ +// DistributedApplicationBuilder +// ============================================================================ + +/** + * Type class for DistributedApplicationBuilder. + */ +export class DistributedApplicationBuilder { + constructor(private _handle: IDistributedApplicationBuilderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the AppHostDirectory property */ + appHostDirectory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.appHostDirectory', + { context: this._handle } + ); + }, + }; + + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + + /** Builds the distributed application */ + /** @internal */ + async _buildInternal(): Promise { + const rpcArgs: Record = { context: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/build', + rpcArgs + ); + return new DistributedApplication(result, this._client); + } + + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._buildInternal()); + } + + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + + /** Adds a connection string with a builder callback */ + /** @internal */ + async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { + const connectionStringBuilderId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; + const obj = new ReferenceExpressionBuilder(objHandle, this._client); + await connectionStringBuilder(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringBuilder', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); + } + + /** Adds a container registry resource */ + /** @internal */ + async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { + 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 ContainerRegistryResource(result, this._client); + } + + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + } + + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); + } + + /** Adds a container resource built from a Dockerfile */ + /** @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 ContainerResource(result, this._client); + } + + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + } + + /** Adds a .NET tool resource */ + /** @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 DotnetToolResource(result, this._client); + } + + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + } + + /** Adds an executable resource */ + /** @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 ExecutableResource(result, this._client); + } + + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + } + + /** Adds an external service resource */ + /** @internal */ + async _addExternalServiceInternal(name: string, url: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, url }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalService', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + } + + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + + /** Adds a parameter resource */ + /** @internal */ + async _addParameterInternal(name: string, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameter', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + } + + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + + /** Adds a parameter sourced from configuration */ + /** @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 ParameterResource(result, this._client); + } + + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + } + + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + + /** Adds a connection string resource */ + /** @internal */ + async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionString', + rpcArgs + ); + return new ResourceWithConnectionString(result, this._client); + } + + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + const environmentVariableName = options?.environmentVariableName; + return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + } + + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + + /** Adds a .NET project resource */ + /** @internal */ + async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProject', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + } + + /** Adds a project resource with configuration options */ + /** @internal */ + async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithOptions', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', rpcArgs ); - return new DistributedApplication(result, this._client); - } - - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._buildInternal()); } - /** Adds a connection string with a reference expression */ - /** @internal */ - async _addConnectionString1Internal(name: string, connectionStringExpression: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringExpression', + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionString1Internal(name, connectionStringExpression)); + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); } - /** Adds a connection string with a builder callback */ - /** @internal */ - async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { - const connectionStringBuilderId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ReferenceExpressionBuilderHandle; - const obj = new ReferenceExpressionBuilder(objHandle, this._client); - await connectionStringBuilder(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, connectionStringBuilder: connectionStringBuilderId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionStringBuilder', + /** Checks if the environment matches the specified name */ + async isEnvironment(environmentName: string): Promise { + const rpcArgs: Record = { environment: this._handle, environmentName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isEnvironment', rpcArgs ); - return new ConnectionStringResource(result, this._client); } - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._addConnectionStringBuilderInternal(name, connectionStringBuilder)); +} + +/** + * Thenable wrapper for HostEnvironment that enables fluent chaining. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds a container registry resource */ - /** @internal */ - async _addContainerRegistryInternal(name: string, endpoint: ParameterResource, repository?: ParameterResource): Promise { - 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 ContainerRegistryResource(result, this._client); + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); } - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); } - /** Adds a container registry with string endpoint */ - /** @internal */ - async _addContainerRegistry1Internal(name: string, endpoint: string, repository?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpoint }; - if (repository !== undefined) rpcArgs.repository = repository; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainerRegistryFromString', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); } - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - const repository = options?.repository; - return new ContainerRegistryResourcePromise(this._addContainerRegistry1Internal(name, endpoint, repository)); + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); } - /** Adds a container resource */ +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', + async _logInformationInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logInformation', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._logInformationInternal(message)); } - /** Adds a container resource built from a Dockerfile */ + /** Logs a warning message */ /** @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', + async _logWarningInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logWarning', rpcArgs ); - return new ContainerResource(result, this._client); + return this; } - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - const dockerfilePath = options?.dockerfilePath; - const stage = options?.stage; - return new ContainerResourcePromise(this._addDockerfileInternal(name, contextPath, dockerfilePath, stage)); + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._logWarningInternal(message)); } - /** Adds a .NET tool resource */ + /** Logs an error message */ /** @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', + async _logErrorInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logError', rpcArgs ); - return new DotnetToolResource(result, this._client); + return this; } - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._addDotnetToolInternal(name, packageId)); + logError(message: string): LoggerPromise { + return new LoggerPromise(this._logErrorInternal(message)); } - /** Adds an executable resource */ + /** Logs a debug message */ /** @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', + async _logDebugInternal(message: string): Promise { + const rpcArgs: Record = { logger: this._handle, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logDebug', rpcArgs ); - return new ExecutableResource(result, this._client); + return this; } - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._addExecutableInternal(name, command, workingDirectory, args)); + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._logDebugInternal(message)); } - /** Adds an external service resource */ + /** Logs a message with specified level */ /** @internal */ - async _addExternalServiceInternal(name: string, url: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, url }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalService', + async _logInternal(level: string, message: string): Promise { + const rpcArgs: Record = { logger: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/log', rpcArgs ); - return new ExternalServiceResource(result, this._client); + return this; } - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._logInternal(level, message)); } - /** Adds an external service with a URI */ - /** @internal */ - async _addExternalService2Internal(name: string, uri: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, uri }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceUri', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService2Internal(name, uri)); + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); } - /** Adds an external service with a parameter URL */ - /** @internal */ - async _addExternalService1Internal(name: string, urlParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, name, urlParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addExternalServiceParameter', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); } - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._addExternalService1Internal(name, urlParameter)); + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); } - /** Adds a parameter resource */ - /** @internal */ - async _addParameterInternal(name: string, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameter', - rpcArgs - ); - return new ParameterResource(result, this._client); + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); } - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterInternal(name, secret)); + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); } - /** Adds a parameter with a default value */ +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ /** @internal */ - async _addParameter1Internal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; - if (secret !== undefined) rpcArgs.secret = secret; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addParameterWithValue', + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', rpcArgs ); - return new ParameterResource(result, this._client); + return new Logger(result, this._client); } - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - const publishValueAsDefault = options?.publishValueAsDefault; - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameter1Internal(name, value, publishValueAsDefault, secret)); + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); } - /** Adds a parameter sourced from configuration */ +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); + } + +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ /** @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', + 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 ParameterResource(result, this._client); + return new ReportingTask(result, this._client); } - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - const secret = options?.secret; - return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); } - /** Adds a connection string resource */ + /** Creates a reporting task with Markdown-formatted status text */ /** @internal */ - async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - if (environmentVariableName !== undefined) rpcArgs.environmentVariableName = environmentVariableName; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addConnectionString', + 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 ResourceWithConnectionString(result, this._client); + return new ReportingTask(result, this._client); } - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - const environmentVariableName = options?.environmentVariableName; - return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); } - /** Adds a .NET project resource */ + /** Logs a plain-text message for the reporting step */ /** @internal */ - async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, projectPath, launchProfileName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProject', + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', rpcArgs ); - return new ProjectResource(result, this._client); + return this; } - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectInternal(name, projectPath, launchProfileName)); + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); } - /** Adds a project resource with configuration options */ + /** Logs a Markdown-formatted message for the reporting step */ /** @internal */ - async _addProjectWithOptionsInternal(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, projectPath, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addProjectWithOptions', + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', rpcArgs ); - return new ProjectResource(result, this._client); + return this; } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); } - /** Adds a C# application resource */ + /** Completes the reporting step with plain-text completion text */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + 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 new ProjectResource(result, this._client); + return this; } - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); } - /** Adds a C# application resource with configuration options */ + /** Completes the reporting step with Markdown-formatted completion text */ /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', + 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 new CSharpAppResource(result, this._client); + return this; } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } - /** Adds an Azure Bicep template resource from a file */ - /** @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 AzureBicepResource(result, this._client); +} + +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - /** @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 AzureBicepResource(result, this._client); + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); } - /** Adds an Azure provisioning resource to the application model */ + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); + } + + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); + } + + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); + } + +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ /** @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 AzureResourceInfrastructure(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', + 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 new AzureProvisioningResource(result, this._client); + return this; } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); } - /** Adds Azure provisioning services to the distributed application builder */ + /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _addAzureProvisioningInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', + 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 new DistributedApplicationBuilder(result, this._client); + return this; } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } - /** Adds the shared Azure environment resource to the application model */ + /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + 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 new AzureEnvironmentResource(result, this._client); + return this; } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } - /** Adds an Azure user-assigned identity resource */ + /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _addAzureUserAssignedIdentityInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureUserAssignedIdentity', + 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 new AzureUserAssignedIdentityResource(result, this._client); + return this; } - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); } - /** Adds a connection string with a reference expression */ - addConnectionString1(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionString1(name, connectionStringExpression))); + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } - /** Adds a container registry with string endpoint */ - addContainerRegistry1(name: string, endpoint: string, options?: AddContainerRegistry1Options): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry1(name, endpoint, options))); +} + +// ============================================================================ +// ServiceProvider +// ============================================================================ + +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); } - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); } - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); } - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); } - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); } - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); } - /** Adds an external service with a URI */ - addExternalService2(name: string, uri: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService2(name, uri))); + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); } - /** Adds an external service with a parameter URL */ - addExternalService1(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService1(name, urlParameter))); + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); } - /** Adds a parameter with a default value */ - addParameter1(name: string, value: string, options?: AddParameter1Options): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter1(name, value, options))); + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); +} + +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); } - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); +} + +// ============================================================================ +// UserSecretsManager +// ============================================================================ + +/** + * Type class for UserSecretsManager. + */ +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + /** Saves state to user secrets from a JSON string */ + /** @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; } - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); } -} - -// ============================================================================ -// DistributedApplicationEventing -// ============================================================================ - -/** - * Type class for DistributedApplicationEventing. - */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} - - /** Serialize for JSON-RPC transport */ - toJSON(): MarshalledHandle { return this._handle.toJSON(); } - - /** Invokes the Unsubscribe method */ + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; await this._client.invokeCapability( - 'Aspire.Hosting.Eventing/IDistributedApplicationEventing.unsubscribe', + 'Aspire.Hosting/getOrSetSecret', rpcArgs ); return this; } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } /** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } @@ -2434,11 +4673,26 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2453,7 +4707,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -2496,36 +4750,6 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureBicepResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -2603,6 +4827,215 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** Gets an output reference from an Azure Bicep template resource */ + 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): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -2652,23 +5085,9 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -2677,28 +5096,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -2707,13 +5113,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -2722,8 +5130,9 @@ export class AzureBicepResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -2823,16 +5237,6 @@ export class AzureBicepResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -2853,6 +5257,71 @@ export class AzureBicepResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -2873,29 +5342,19 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -3120,11 +5579,26 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3139,7 +5613,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -3182,36 +5656,6 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureEnvironmentResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -3289,6 +5733,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withLocationInternal(location: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, location }; @@ -3396,6 +5920,11 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3416,16 +5945,6 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -3446,6 +5965,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets the Azure location for the shared Azure environment resource */ withLocation(location: ParameterResource): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withLocation(location))); @@ -3678,11 +6217,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -3697,7 +6251,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -3740,36 +6294,6 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureProvisioningResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -3813,38 +6337,118 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 AzureProvisioningResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new AzureProvisioningResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); } /** Gets an output reference from an Azure Bicep template resource */ @@ -3976,6 +6580,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -4025,23 +6649,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -4050,28 +6660,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -4080,13 +6677,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -4095,8 +6694,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4196,16 +6801,6 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -4226,6 +6821,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Gets an output reference from an Azure Bicep template resource */ getOutput(name: string): Promise { return this._promise.then(obj => obj.getOutput(name)); @@ -4271,6 +6886,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -4291,29 +6911,19 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -4538,11 +7148,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -4557,7 +7182,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -4600,36 +7225,6 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 AzureUserAssignedIdentityResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -4707,6 +7302,86 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); + } + /** Gets an output reference from an Azure Bicep template resource */ async getOutput(name: string): Promise { const rpcArgs: Record = { builder: this._handle, name }; @@ -4905,23 +7580,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -4930,28 +7591,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -4960,13 +7608,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -4975,8 +7625,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5076,16 +7732,6 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -5106,6 +7752,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Gets an output reference from an Azure Bicep template resource */ getOutput(name: string): Promise { return this._promise.then(obj => obj.getOutput(name)); @@ -5176,29 +7842,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -5264,7 +7920,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -5273,8 +7929,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -5405,7 +8070,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5435,7 +8100,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5481,7 +8146,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5530,11 +8195,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5549,7 +8229,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5562,64 +8242,34 @@ export class ConnectionStringResource extends ResourceBuilderBase { - 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 ConnectionStringResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { - const iconVariant = options?.iconVariant; - return new ConnectionStringResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ConnectionStringResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._excludeFromMcpInternal()); - } - - /** @internal */ - private async _withRemoteImageNameInternal(remoteImageName: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; + const rpcArgs: Record = { builder: this._handle, iconName }; + if (iconVariant !== undefined) rpcArgs.iconVariant = iconVariant; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', + 'Aspire.Hosting/withIconName', rpcArgs ); return new ConnectionStringResource(result, this._client); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ConnectionStringResourcePromise { + const iconVariant = options?.iconVariant; + return new ConnectionStringResourcePromise(this._withIconNameInternal(iconName, iconVariant)); } /** @internal */ - private async _withRemoteImageTagInternal(remoteImageTag: string): Promise { - const rpcArgs: Record = { builder: this._handle, remoteImageTag }; + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageTag', + 'Aspire.Hosting/excludeFromMcp', rpcArgs ); return new ConnectionStringResource(result, this._client); } - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._excludeFromMcpInternal()); } /** @internal */ @@ -5699,6 +8349,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -5731,8 +8481,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -5741,6 +8491,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -5811,6 +8566,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5831,16 +8591,6 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -5861,6 +8611,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -6083,11 +8858,26 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -6102,7 +8892,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -6145,36 +8935,6 @@ export class ContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ContainerRegistryResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ContainerRegistryResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -6252,6 +9012,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -6329,6 +9169,11 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6349,16 +9194,6 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -6379,6 +9214,26 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -6594,7 +9449,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -6603,8 +9458,8 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new ContainerResource(result, this._client); @@ -6623,6 +9478,27 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -6738,73 +9614,23 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const rpcArgs: Record = { builder: this._handle, command }; + if (helpLink !== undefined) rpcArgs.helpLink = helpLink; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -6812,15 +9638,15 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -6838,6 +9664,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -6924,52 +9765,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -7269,7 +10097,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -7299,7 +10127,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -7345,7 +10173,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -7450,7 +10278,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -7477,11 +10305,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -7496,7 +10339,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -7694,6 +10537,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -7728,7 +10671,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ContainerResource(result, this._client); @@ -7821,8 +10764,8 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -7831,6 +10774,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -7871,31 +10819,21 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -7921,21 +10859,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -8081,6 +11014,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -8141,6 +11079,31 @@ export class ContainerResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -8281,58 +11244,50 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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 CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironment', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -8343,43 +11298,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -8468,52 +11418,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -8798,7 +11735,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8828,7 +11765,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8858,7 +11795,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -8904,7 +11841,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9009,7 +11946,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9022,25 +11959,40 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle }; + private async _withoutHttpsCertificateInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', + 'Aspire.Hosting/withBuilderRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withoutHttpsCertificateInternal()); + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); } /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9055,7 +12007,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9234,6 +12186,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -9268,7 +12320,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9331,36 +12383,31 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -9386,21 +12433,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -9551,6 +12593,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9606,6 +12653,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -9888,41 +12960,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -9933,43 +12975,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -10058,52 +13095,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -10403,7 +13427,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10433,7 +13457,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10479,7 +13503,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10584,7 +13608,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10611,11 +13635,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10630,7 +13669,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10809,6 +13848,106 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -10843,7 +13982,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -10948,34 +14087,24 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -11001,21 +14130,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -11161,6 +14285,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -11216,6 +14345,31 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -11276,6 +14430,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -11343,41 +14562,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -11388,43 +14577,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -11513,52 +14697,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -11858,7 +15029,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -11888,7 +15059,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -11934,7 +15105,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12039,7 +15210,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12066,11 +15237,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12085,7 +15271,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12206,62 +15392,162 @@ export class ExecutableResource extends ResourceBuilderBase Promise, options?: WithPipelineStepFactoryOptions): ExecutableResourcePromise { - const dependsOn = options?.dependsOn; - const requiredBy = options?.requiredBy; - const tags = options?.tags; - const description = options?.description; - return new ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + /** Adds a pipeline step to the resource */ + 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 ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(argHandle, this._client); await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', + 'Aspire.Hosting/onResourceEndpointsAllocated', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); } /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(objHandle, this._client); - await callback(obj); + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfiguration', + 'Aspire.Hosting/onResourceReady', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); } /** @internal */ @@ -12298,7 +15584,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12336,6 +15622,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -12356,31 +15662,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -12406,21 +15702,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -12566,6 +15857,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -12621,6 +15917,31 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -12877,11 +16198,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -12896,7 +16232,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -12939,36 +16275,6 @@ export class ExternalServiceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ExternalServiceResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ExternalServiceResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -13046,6 +16352,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -13128,6 +16514,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -13148,16 +16539,6 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -13178,6 +16559,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -13417,11 +16818,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -13436,7 +16852,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -13479,36 +16895,6 @@ export class ParameterResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, remoteImageName }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRemoteImageName', - rpcArgs - ); - return new ParameterResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ParameterResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -13586,6 +16972,86 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -13668,6 +17134,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -13688,16 +17159,6 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -13718,6 +17179,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -13813,74 +17294,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -13888,15 +17371,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -13914,6 +17397,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -14000,52 +17498,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -14330,7 +17815,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -14360,7 +17845,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -14390,7 +17875,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -14436,7 +17921,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -14541,7 +18026,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -14568,11 +18053,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -14587,7 +18087,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -14766,6 +18266,106 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -14800,7 +18400,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ProjectResource(result, this._client); @@ -14853,29 +18453,29 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -14883,6 +18483,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -14908,21 +18513,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -15073,6 +18673,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15128,6 +18733,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -15203,23 +18833,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -15228,28 +18844,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -15258,13 +18861,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/asExisting', rpcArgs @@ -15273,8 +18878,9 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -15314,29 +18920,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } /** Marks an Azure resource as existing in both run and publish modes */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -15350,11 +18946,41 @@ export class ComputeResource extends ResourceBuilderBase super(handle, 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 ComputeResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ComputeResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + /** @internal */ private async _withAzureUserAssignedIdentityInternal(identityResourceBuilder: AzureUserAssignedIdentityResource): Promise { const rpcArgs: Record = { builder: this._handle, identityResourceBuilder }; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/withAzureUserAssignedIdentity', + 'Aspire.Hosting.Azure/withUserAssignedIdentityAzureUserAssignedIdentity', rpcArgs ); return new ComputeResource(result, this._client); @@ -15382,6 +19008,16 @@ export class ComputeResourcePromise implements PromiseLike { return this._promise.then(onfulfilled, onrejected); } + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ComputeResourcePromise { + return new ComputeResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); + } + /** Associates an Azure user-assigned identity with a compute resource */ withAzureUserAssignedIdentity(identityResourceBuilder: AzureUserAssignedIdentityResource): ComputeResourcePromise { return new ComputeResourcePromise(this._promise.then(obj => obj.withAzureUserAssignedIdentity(identityResourceBuilder))); @@ -15402,7 +19038,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -15657,11 +19293,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -15676,7 +19327,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -15719,36 +19370,6 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._excludeFromMcpInternal()); } - /** @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 Resource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 Resource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - /** @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) => { @@ -15826,6 +19447,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + } /** @@ -15903,6 +19604,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15923,16 +19629,6 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.excludeFromMcp())); } - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageName(remoteImageName))); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ResourcePromise { - return new ResourcePromise(this._promise.then(obj => obj.withRemoteImageTag(remoteImageTag))); - } - /** Adds a pipeline step to the resource */ withPipelineStepFactory(stepName: string, callback: (arg: PipelineStepContext) => Promise, options?: WithPipelineStepFactoryOptions): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withPipelineStepFactory(stepName, callback, options))); @@ -15953,6 +19649,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + } // ============================================================================ @@ -16063,7 +19779,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -16072,8 +19788,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -16109,8 +19854,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -16119,6 +19864,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -16407,6 +20162,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -16474,6 +20249,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -16516,41 +20296,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -16561,43 +20311,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -16631,52 +20376,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -16759,7 +20491,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -16843,31 +20575,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -16878,21 +20600,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -16940,34 +20657,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -16981,7 +20670,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -17011,7 +20700,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -17042,7 +20731,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -17161,7 +20850,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { const error = reason instanceof Error ? reason : new Error(String(reason)); - if (reason instanceof CapabilityError) { + 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) { @@ -17192,8 +20883,12 @@ process.on('unhandledRejection', (reason: unknown) => { }); process.on('uncaughtException', (error: Error) => { - console.error(`\n❌ Uncaught Exception: ${error.message}`); - if (error.stack) { + if (error instanceof AppHostUsageError) { + console.error(`\n❌ AppHost Error: ${error.message}`); + } else { + console.error(`\n❌ Uncaught Exception: ${error.message}`); + } + if (!(error instanceof AppHostUsageError) && error.stack) { console.error(error.stack); } process.exit(1); @@ -17204,23 +20899,46 @@ process.on('uncaughtException', (error: Error) => { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureEnvironmentResource', (handle, client) => new AzureEnvironmentResource(handle as AzureEnvironmentResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureProvisioningResource', (handle, client) => new AzureProvisioningResource(handle as AzureProvisioningResourceHandle, client)); @@ -17243,6 +20961,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/base.ts index 7778b0f1737..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -43,22 +43,46 @@ export class ReferenceExpression { private readonly _format?: string; private readonly _valueProviders?: unknown[]; + // Conditional mode fields + private readonly _condition?: unknown; + private readonly _whenTrue?: ReferenceExpression; + private readonly _whenFalse?: ReferenceExpression; + private readonly _matchValue?: string; + // Handle mode fields (when wrapping a server-returned handle) private readonly _handle?: Handle; private readonly _client?: AspireClient; constructor(format: string, valueProviders: unknown[]); constructor(handle: Handle, client: AspireClient); - constructor(handleOrFormat: Handle | string, clientOrValueProviders: AspireClient | unknown[]) { - if (typeof handleOrFormat === 'string') { - this._format = handleOrFormat; - this._valueProviders = clientOrValueProviders as unknown[]; + constructor(condition: unknown, matchValue: string, whenTrue: ReferenceExpression, whenFalse: ReferenceExpression); + constructor( + handleOrFormatOrCondition: Handle | string | unknown, + clientOrValueProvidersOrMatchValue: AspireClient | unknown[] | string, + whenTrueOrWhenFalse?: ReferenceExpression, + whenFalse?: ReferenceExpression + ) { + if (typeof handleOrFormatOrCondition === 'string') { + this._format = handleOrFormatOrCondition; + this._valueProviders = clientOrValueProvidersOrMatchValue as unknown[]; + } else if (handleOrFormatOrCondition instanceof Handle) { + this._handle = handleOrFormatOrCondition; + this._client = clientOrValueProvidersOrMatchValue as AspireClient; } else { - this._handle = handleOrFormat; - this._client = clientOrValueProviders as AspireClient; + this._condition = handleOrFormatOrCondition; + this._matchValue = (clientOrValueProvidersOrMatchValue as string) ?? 'True'; + this._whenTrue = whenTrueOrWhenFalse; + this._whenFalse = whenFalse; } } + /** + * Gets whether this reference expression is conditional. + */ + get isConditional(): boolean { + return this._condition !== undefined; + } + /** * Creates a reference expression from a tagged template literal. * @@ -82,16 +106,46 @@ export class ReferenceExpression { return new ReferenceExpression(format, valueProviders); } + /** + * Creates a conditional reference expression from its constituent parts. + * + * @param condition - A value provider whose result is compared to matchValue + * @param whenTrue - The expression to use when the condition matches + * @param whenFalse - The expression to use when the condition does not match + * @param matchValue - The value to compare the condition against (defaults to "True") + * @returns A ReferenceExpression instance in conditional mode + */ + static createConditional( + condition: unknown, + matchValue: string, + whenTrue: ReferenceExpression, + whenFalse: ReferenceExpression + ): ReferenceExpression { + return new ReferenceExpression(condition, matchValue, whenTrue, whenFalse); + } + /** * Serializes the reference expression for JSON-RPC transport. - * In template-literal mode, uses the $expr format. + * 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[] } } | MarshalledHandle { + toJSON(): { $expr: { format: string; valueProviders?: unknown[] } | { condition: unknown; whenTrue: unknown; whenFalse: unknown; matchValue: string } } | MarshalledHandle { if (this._handle) { return this._handle.toJSON(); } + if (this.isConditional) { + return { + $expr: { + condition: extractHandleForExpr(this._condition), + whenTrue: this._whenTrue!.toJSON(), + whenFalse: this._whenFalse!.toJSON(), + matchValue: this._matchValue! + } + }; + } + return { $expr: { format: this._format!, @@ -100,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -107,10 +185,17 @@ export class ReferenceExpression { if (this._handle) { return `ReferenceExpression(handle)`; } + if (this.isConditional) { + return `ReferenceExpression(conditional)`; + } return `ReferenceExpression(${this._format})`; } } +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. @@ -136,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -307,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -466,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/transport.ts index 7bddd74beff..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -213,6 +354,76 @@ export class CapabilityError extends Error { } } +/** + * Error thrown when the AppHost script uses the generated SDK incorrectly. + */ +export class AppHostUsageError extends Error { + constructor(message: string) { + super(message); + this.name = 'AppHostUsageError'; + } +} + +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 // ============================================================================ @@ -324,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -346,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -361,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -381,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -411,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -422,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -432,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + 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; - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + let settled = false; - this.socket = net.createConnection(pipePath); + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -475,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -533,39 +935,66 @@ export class AspireClient { throw new Error('Not connected to AppHost'); } - // 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++; + validateCapabilityArgs(capabilityId, args); + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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++; - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + 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 { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/apphost.ts index 26c1b2f02f2..b2dc95327f3 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/apphost.ts @@ -26,11 +26,9 @@ await fileBicep.publishAsConnectionString(); await fileBicep.clearDefaultRoleAssignments(); await fileBicep.getBicepIdentifier(); await fileBicep.isExisting(); -await fileBicep.runAsExisting("file-bicep-existing", "rg-bicep"); -await fileBicep.runAsExistingFromParameters(existingName, existingResourceGroup); -await fileBicep.publishAsExisting("file-bicep-existing", "rg-bicep"); -await fileBicep.publishAsExistingFromParameters(existingName, existingResourceGroup); -await fileBicep.asExisting(existingName, existingResourceGroup); +await fileBicep.runAsExisting("file-bicep-existing", { resourceGroup: "rg-bicep" }); +await fileBicep.publishAsExisting("file-bicep-existing", { resourceGroup: "rg-bicep" }); +await fileBicep.asExisting("file-bicep-existing", { resourceGroup: "rg-bicep" }); const inlineBicep = await builder.addBicepTemplateString("inline-bicep", ` output inlineUrl string = 'https://inline.example.com' @@ -60,11 +58,9 @@ await infrastructure.publishAsConnectionString(); await infrastructure.clearDefaultRoleAssignments(); await infrastructure.getBicepIdentifier(); await infrastructure.isExisting(); -await infrastructure.runAsExisting("infra-existing", "rg-infra"); -await infrastructure.runAsExistingFromParameters(existingName, existingResourceGroup); -await infrastructure.publishAsExisting("infra-existing", "rg-infra"); -await infrastructure.publishAsExistingFromParameters(existingName, existingResourceGroup); -await infrastructure.asExisting(existingName, existingResourceGroup); +await infrastructure.runAsExisting(existingName, { resourceGroup: existingResourceGroup }); +await infrastructure.publishAsExisting(existingName, { resourceGroup: existingResourceGroup }); +await infrastructure.asExisting(existingName, { resourceGroup: existingResourceGroup }); const identity = await builder.addAzureUserAssignedIdentity("identity"); await identity.configureInfrastructure(async infrastructureContext => { @@ -83,11 +79,10 @@ await identity.publishAsConnectionString(); await identity.clearDefaultRoleAssignments(); await identity.getBicepIdentifier(); await identity.isExisting(); -await identity.runAsExisting("identity-existing", "rg-identity"); -await identity.runAsExistingFromParameters(existingName, existingResourceGroup); -await identity.publishAsExisting("identity-existing", "rg-identity"); -await identity.publishAsExistingFromParameters(existingName, existingResourceGroup); -await identity.asExisting(existingName, existingResourceGroup); +await identity.runAsExisting("identity-existing", { resourceGroup: "rg-identity" }); +await identity.publishAsExisting("identity-existing", { resourceGroup: "rg-identity" }); +await identity.publishAsExisting(existingName, { resourceGroup: existingResourceGroup }); +await identity.asExisting("identity-existing", { resourceGroup: "rg-identity" }); await container.withEnvironmentFromOutput("INFRA_URL", infrastructureOutput); await container.withEnvironmentFromKeyVaultSecret("SECRET_FROM_IDENTITY", identity); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..711232c0e1a --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/aspire.config.json @@ -0,0 +1,18 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "profiles": { + "https": { + "applicationUrl": "https://localhost:29550;http://localhost:28731", + "environmentVariables": { + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10775", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13119" + } + } + }, + "packages": { + "Aspire.Hosting.Azure": "" + } +} \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.aspire/settings.json deleted file mode 100644 index f6c28fe7785..00000000000 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.aspire/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", - "packages": { - "Aspire.Hosting.Foundry": "" - } -} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/.codegen-hash index e93f06c780e..2e2c6f0f63f 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -DE722F4CC472CDD941E57780B800FF7D4A8BFD3EAE29E5192958620B186DCE67 \ No newline at end of file +0935C83023F63F2C642664226C2F7D766F8B1AF47D581021687E11663CB37AD8 \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/aspire.ts index 910714292a0..39301c95c6c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/aspire.ts @@ -9,6 +9,7 @@ import { Handle, MarshalledHandle, AppHostUsageError, + CancellationToken, CapabilityError, registerCallback, wrapIfHandle, @@ -129,9 +130,21 @@ type FoundryResourceHandle = Handle<'Aspire.Hosting.Foundry/Aspire.Hosting.Found /** Handle to HostedAgentConfiguration */ type HostedAgentConfigurationHandle = Handle<'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration'>; +/** 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 ConnectionStringAvailableEvent */ +type ConnectionStringAvailableEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent'>; + /** Handle to ContainerRegistryResource */ type ContainerRegistryResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerRegistryResource'>; @@ -141,6 +154,9 @@ type ContainerResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Application /** 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 DotnetToolResource */ type DotnetToolResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.DotnetToolResource'>; @@ -165,6 +181,9 @@ type IComputeResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationM /** Handle to IContainerFilesDestinationResource */ type IContainerFilesDestinationResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IContainerFilesDestinationResource'>; +/** Handle to InitializeResourceEvent */ +type InitializeResourceEventHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent'>; + /** Handle to IResource */ type IResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource'>; @@ -195,15 +214,27 @@ type ReferenceExpressionHandle = Handle<'Aspire.Hosting/Aspire.Hosting.Applicati /** 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 UpdateCommandStateContext */ +type UpdateCommandStateContextHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext'>; + /** Handle to ConnectionStringResource */ type ConnectionStringResourceHandle = Handle<'Aspire.Hosting/Aspire.Hosting.ConnectionStringResource'>; @@ -228,18 +259,33 @@ type IDistributedApplicationBuilderHandle = Handle<'Aspire.Hosting/Aspire.Hostin /** 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 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 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'>; @@ -252,12 +298,18 @@ type ListanyHandle = Handle<'Aspire.Hosting/List'>; /** 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 string[] */ type stringArrayHandle = Handle<'string[]'>; @@ -446,6 +498,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -483,6 +541,27 @@ export interface FoundryModel { format?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -517,6 +596,10 @@ export interface AddContainerOptions { containerName?: string; } +export interface AddContainerRegistryFromStringOptions { + repository?: string; +} + export interface AddContainerRegistryOptions { repository?: ParameterResource; } @@ -546,6 +629,16 @@ export interface AddParameterOptions { secret?: boolean; } +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; + secret?: boolean; +} + export interface AddQueueOptions { queueName?: string; } @@ -558,8 +651,59 @@ export interface AppendValueProviderOptions { format?: string; } +export interface AsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +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 CreateMarkdownTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface CreateTaskOptions { + cancellationToken?: AbortSignal | CancellationToken; +} + export interface GetValueAsyncOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; +} + +export interface PublishAsDockerFileOptions { + configure?: (obj: ContainerResource) => Promise; +} + +export interface PublishAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + +export interface PublishAsHostedAgentOptions { + project?: AzureCognitiveServicesProjectResource; + configure?: (obj: HostedAgentConfiguration) => Promise; +} + +export interface PublishResourceUpdateOptions { + state?: string; + stateStyle?: string; } export interface RunAsEmulator1Options { @@ -570,23 +714,38 @@ export interface RunAsEmulatorOptions { configureContainer?: (obj: AzureCosmosDBEmulatorResource) => Promise; } +export interface RunAsExistingOptions { + resourceGroup?: string | ParameterResource; +} + export interface RunAsPreviewEmulatorOptions { configureContainer?: (obj: AzureCosmosDBEmulatorResource) => Promise; } export interface RunOptions { - cancellationToken?: AbortSignal; + cancellationToken?: AbortSignal | CancellationToken; } -export interface PublishAsHostedAgentOptions { - project?: AzureCognitiveServicesProjectResource; - configure?: (obj: HostedAgentConfiguration) => Promise; +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 WaitForResourceStateOptions { + targetState?: string; +} + export interface WithApiVersionCheckOptions { enable?: boolean; } @@ -599,6 +758,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDataBindMountOptions { path?: string; isReadOnly?: boolean; @@ -713,6 +878,7 @@ export interface WithPurgeTaskOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -732,6 +898,43 @@ export interface WithVolumeOptions { isReadOnly?: boolean; } +// ============================================================================ +// AfterResourcesCreatedEvent +// ============================================================================ + +/** + * Type class for AfterResourcesCreatedEvent. + */ +export class AfterResourcesCreatedEvent { + constructor(private _handle: AfterResourcesCreatedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/AfterResourcesCreatedEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // AzureResourceInfrastructure // ============================================================================ @@ -773,6 +976,80 @@ export class AzureResourceInfrastructure { } +// ============================================================================ +// BeforeResourceStartedEvent +// ============================================================================ + +/** + * Type class for BeforeResourceStartedEvent. + */ +export class BeforeResourceStartedEvent { + constructor(private _handle: BeforeResourceStartedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeResourceStartedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// BeforeStartEvent +// ============================================================================ + +/** + * Type class for BeforeStartEvent. + */ +export class BeforeStartEvent { + constructor(private _handle: BeforeStartEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/BeforeStartEvent.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + +} + // ============================================================================ // BicepOutputReference // ============================================================================ @@ -847,11 +1124,12 @@ export class CommandLineArgsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); }, }; @@ -866,6 +1144,65 @@ export class CommandLineArgsCallbackContext { }, }; + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/CommandLineArgsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ConnectionStringAvailableEvent +// ============================================================================ + +/** + * Type class for ConnectionStringAvailableEvent. + */ +export class ConnectionStringAvailableEvent { + constructor(private _handle: ConnectionStringAvailableEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ConnectionStringAvailableEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -883,9 +1220,9 @@ export class DistributedApplication { /** Runs the distributed application */ /** @internal */ - async _runInternal(cancellationToken?: AbortSignal): Promise { + async _runInternal(cancellationToken?: AbortSignal | CancellationToken): Promise { const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); await this._client.invokeCapability( 'Aspire.Hosting/run', rpcArgs @@ -959,6 +1296,17 @@ export class DistributedApplicationExecutionContext { }, }; + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/DistributedApplicationExecutionContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the IsPublishMode property */ isPublishMode = { get: async (): Promise => { @@ -981,6 +1329,70 @@ export class DistributedApplicationExecutionContext { } +// ============================================================================ +// DistributedApplicationModel +// ============================================================================ + +/** + * Type class for DistributedApplicationModel. + */ +export class DistributedApplicationModel { + constructor(private _handle: DistributedApplicationModelHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets resources from the distributed application model */ + async getResources(): Promise { + const rpcArgs: Record = { model: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getResources', + rpcArgs + ); + } + + /** Finds a resource by name */ + /** @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 Resource(result, this._client); + } + + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._findResourceByNameInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationModel that enables fluent chaining. + */ +export class DistributedApplicationModelPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationModel) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets resources from the distributed application model */ + getResources(): Promise { + return this._promise.then(obj => obj.getResources()); + } + + /** Finds a resource by name */ + findResourceByName(name: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.findResourceByName(name))); + } + +} + // ============================================================================ // EndpointReference // ============================================================================ @@ -994,6 +1406,17 @@ export class EndpointReference { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EndpointReference.resource', + { context: this._handle } + ); + return new ResourceWithEndpoints(handle, this._client); + }, + }; + /** Gets the EndpointName property */ endpointName = { get: async (): Promise => { @@ -1124,7 +1547,7 @@ export class EndpointReference { async getValueAsync(options?: GetValueAsyncOptions): Promise { const cancellationToken = options?.cancellationToken; const rpcArgs: Record = { context: this._handle }; - if (cancellationToken !== undefined) rpcArgs.cancellationToken = cancellationToken; + if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken); return await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/getValueAsync', rpcArgs @@ -1242,11 +1665,34 @@ export class EnvironmentCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/EnvironmentCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); }, }; @@ -1276,6 +1722,17 @@ export class ExecuteCommandContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the ResourceName property */ resourceName = { get: async (): Promise => { @@ -1294,20 +1751,182 @@ export class ExecuteCommandContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + 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): Promise => { + set: async (value: AbortSignal | CancellationToken): Promise => { await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ExecuteCommandContext.setCancellationToken', + { context: this._handle, value: CancellationToken.fromValue(value) } + ); + } + }; + +} + +// ============================================================================ +// HostedAgentConfiguration +// ============================================================================ + +/** + * Type class for HostedAgentConfiguration. + */ +export class HostedAgentConfiguration { + constructor(private _handle: HostedAgentConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Description property */ + description = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.description', + { context: this._handle } + ); + }, + set: async (value: string): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.setDescription', { context: this._handle, value } ); } }; + /** Gets the Metadata property */ + private _metadata?: AspireDict; + get metadata(): AspireDict { + if (!this._metadata) { + this._metadata = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.metadata', + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.metadata' + ); + } + return this._metadata; + } + + /** Gets the Cpu property */ + cpu = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.cpu', + { context: this._handle } + ); + }, + set: async (value: number): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.setCpu', + { context: this._handle, value } + ); + } + }; + + /** Gets the Memory property */ + memory = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.memory', + { context: this._handle } + ); + }, + set: async (value: number): Promise => { + await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.setMemory', + { context: this._handle, value } + ); + } + }; + + /** Gets the EnvironmentVariables property */ + private _environmentVariables?: AspireDict; + get environmentVariables(): AspireDict { + if (!this._environmentVariables) { + this._environmentVariables = new AspireDict( + this._handle, + this._client, + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.environmentVariables', + 'Aspire.Hosting.Foundry/HostedAgentConfiguration.environmentVariables' + ); + } + return this._environmentVariables; + } + +} + +// ============================================================================ +// InitializeResourceEvent +// ============================================================================ + +/** + * Type class for InitializeResourceEvent. + */ +export class InitializeResourceEvent { + constructor(private _handle: InitializeResourceEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Eventing property */ + eventing = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.eventing', + { context: this._handle } + ); + return new DistributedApplicationEventing(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the Notifications property */ + notifications = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.notifications', + { context: this._handle } + ); + return new ResourceNotificationService(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/InitializeResourceEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + } // ============================================================================ @@ -1323,6 +1942,17 @@ export class PipelineConfigurationContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + /** Gets the Steps property */ steps = { get: async (): Promise => { @@ -1339,6 +1969,17 @@ export class PipelineConfigurationContext { } }; + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineConfigurationContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets pipeline steps with the specified tag */ async getStepsByTag(tag: string): Promise { const rpcArgs: Record = { context: this._handle, tag }; @@ -1370,6 +2011,93 @@ export class PipelineConfigurationContextPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + + /** Gets the ExecutionContext property */ + executionContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.executionContext', + { context: this._handle } + ); + return new DistributedApplicationExecutionContext(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + + /** Gets the CancellationToken property */ + 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) } + ); + } + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); + }, + }; + +} + // ============================================================================ // PipelineStep // ============================================================================ @@ -1457,6 +2185,17 @@ export class PipelineStep { return this._tags; } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStep.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Adds a dependency on another step by name */ /** @internal */ async _dependsOnInternal(stepName: string): Promise { @@ -1527,6 +2266,39 @@ export class PipelineStepContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.pipelineContext', + { context: this._handle } + ); + return new PipelineContext(handle, this._client); + }, + }; + + /** Gets the ReportingStep property */ + reportingStep = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.reportingStep', + { context: this._handle } + ); + return new ReportingStep(handle, this._client); + }, + }; + + /** Gets the Model property */ + model = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.model', + { context: this._handle } + ); + return new DistributedApplicationModel(handle, this._client); + }, + }; + /** Gets the ExecutionContext property */ executionContext = { get: async (): Promise => { @@ -1538,169 +2310,220 @@ export class PipelineStepContext { }, }; + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); + }, + }; + /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.Pipelines/PipelineStepContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Summary property */ + summary = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepContext.summary', + { context: this._handle } + ); + return new PipelineSummary(handle, this._client); }, }; } // ============================================================================ -// ProjectResourceOptions +// PipelineStepFactoryContext // ============================================================================ /** - * Type class for ProjectResourceOptions. + * Type class for PipelineStepFactoryContext. */ -export class ProjectResourceOptions { - constructor(private _handle: ProjectResourceOptionsHandle, private _client: AspireClientRpc) {} +export class PipelineStepFactoryContext { + constructor(private _handle: PipelineStepFactoryContextHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the LaunchProfileName property */ - launchProfileName = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.launchProfileName', + /** Gets the PipelineContext property */ + pipelineContext = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.pipelineContext', { context: this._handle } ); + return new PipelineContext(handle, this._client); }, - set: async (value: string): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.setLaunchProfileName', - { context: this._handle, value } - ); - } }; - /** Gets the ExcludeLaunchProfile property */ - excludeLaunchProfile = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.excludeLaunchProfile', + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Pipelines/PipelineStepFactoryContext.resource', { context: this._handle } ); + return new Resource(handle, this._client); }, - set: async (value: boolean): Promise => { - await this._client.invokeCapability( - 'Aspire.Hosting/ProjectResourceOptions.setExcludeLaunchProfile', - { context: this._handle, value } - ); - } }; - /** Gets the ExcludeKestrelEndpoints property */ - 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 } - ); - } - }; +} + +// ============================================================================ +// PipelineSummary +// ============================================================================ + +/** + * Type class for PipelineSummary. + */ +export class PipelineSummary { + constructor(private _handle: PipelineSummaryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Add method */ + /** @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 PipelineSummaryPromise(this._addInternal(key, value)); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + /** @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 PipelineSummaryPromise(this._addMarkdownInternal(key, markdownString)); + } + +} + +/** + * Thenable wrapper for PipelineSummary that enables fluent chaining. + */ +export class PipelineSummaryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: PipelineSummary) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Add method */ + add(key: string, value: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.add(key, value))); + } + + /** Adds a Markdown-formatted value to the pipeline summary */ + addMarkdown(key: string, markdownString: string): PipelineSummaryPromise { + return new PipelineSummaryPromise(this._promise.then(obj => obj.addMarkdown(key, markdownString))); + } } // ============================================================================ -// HostedAgentConfiguration +// ProjectResourceOptions // ============================================================================ /** - * Type class for HostedAgentConfiguration. + * Type class for ProjectResourceOptions. */ -export class HostedAgentConfiguration { - constructor(private _handle: HostedAgentConfigurationHandle, private _client: AspireClientRpc) {} +export class ProjectResourceOptions { + constructor(private _handle: ProjectResourceOptionsHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Gets the Description property */ - description = { + /** Gets the LaunchProfileName property */ + launchProfileName = { get: async (): Promise => { return await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.description', + 'Aspire.Hosting/ProjectResourceOptions.launchProfileName', { context: this._handle } ); }, set: async (value: string): Promise => { await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.setDescription', + 'Aspire.Hosting/ProjectResourceOptions.setLaunchProfileName', { context: this._handle, value } ); } }; - /** Gets the Metadata property */ - private _metadata?: AspireDict; - get metadata(): AspireDict { - if (!this._metadata) { - this._metadata = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.metadata', - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.metadata' - ); - } - return this._metadata; - } - - /** Gets the Cpu property */ - cpu = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.cpu', + /** Gets the ExcludeLaunchProfile property */ + excludeLaunchProfile = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeLaunchProfile', { context: this._handle } ); }, - set: async (value: number | null): Promise => { + set: async (value: boolean): Promise => { await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.setCpu', + 'Aspire.Hosting/ProjectResourceOptions.setExcludeLaunchProfile', { context: this._handle, value } ); } }; - /** Gets the Memory property */ - memory = { - get: async (): Promise => { - return await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.memory', + /** Gets the ExcludeKestrelEndpoints property */ + excludeKestrelEndpoints = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/ProjectResourceOptions.excludeKestrelEndpoints', { context: this._handle } ); }, - set: async (value: number | null): Promise => { + set: async (value: boolean): Promise => { await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.setMemory', + 'Aspire.Hosting/ProjectResourceOptions.setExcludeKestrelEndpoints', { context: this._handle, value } ); } }; - /** Gets the EnvironmentVariables property */ - private _environmentVariables?: AspireDict; - get environmentVariables(): AspireDict { - if (!this._environmentVariables) { - this._environmentVariables = new AspireDict( - this._handle, - this._client, - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.environmentVariables', - 'Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration.environmentVariables' - ); - } - return this._environmentVariables; - } } // ============================================================================ @@ -1821,6 +2644,325 @@ export class ReferenceExpressionBuilderPromise implements PromiseLike => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceEndpointsAllocatedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceLoggerService +// ============================================================================ + +/** + * Type class for ResourceLoggerService. + */ +export class ResourceLoggerService { + constructor(private _handle: ResourceLoggerServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Completes the log stream for a resource */ + /** @internal */ + async _completeLogInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { loggerService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/completeLog', + rpcArgs + ); + return this; + } + + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._completeLogInternal(resource)); + } + + /** Completes the log stream by resource name */ + /** @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 ResourceLoggerServicePromise(this._completeLogByNameInternal(resourceName)); + } + +} + +/** + * Thenable wrapper for ResourceLoggerService that enables fluent chaining. + */ +export class ResourceLoggerServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceLoggerService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Completes the log stream for a resource */ + completeLog(resource: ResourceBuilderBase): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLog(resource))); + } + + /** Completes the log stream by resource name */ + completeLogByName(resourceName: string): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.completeLogByName(resourceName))); + } + +} + +// ============================================================================ +// ResourceNotificationService +// ============================================================================ + +/** + * Type class for ResourceNotificationService. + */ +export class ResourceNotificationService { + constructor(private _handle: ResourceNotificationServiceHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Waits for a resource to reach a specified state */ + /** @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 ResourceNotificationServicePromise(this._waitForResourceStateInternal(resourceName, targetState)); + } + + /** Waits for a resource to reach one of the specified states */ + async waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName, targetStates }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceStates', + rpcArgs + ); + } + + /** Waits for a resource to become healthy */ + async waitForResourceHealthy(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/waitForResourceHealthy', + rpcArgs + ); + } + + /** Waits for all dependencies of a resource to be ready */ + /** @internal */ + async _waitForDependenciesInternal(resource: ResourceBuilderBase): Promise { + const rpcArgs: Record = { notificationService: this._handle, resource }; + await this._client.invokeCapability( + 'Aspire.Hosting/waitForDependencies', + rpcArgs + ); + return this; + } + + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._waitForDependenciesInternal(resource)); + } + + /** Tries to get the current state of a resource */ + async tryGetResourceState(resourceName: string): Promise { + const rpcArgs: Record = { notificationService: this._handle, resourceName }; + return await this._client.invokeCapability( + 'Aspire.Hosting/tryGetResourceState', + rpcArgs + ); + } + + /** Publishes an update for a resource's state */ + /** @internal */ + async _publishResourceUpdateInternal(resource: ResourceBuilderBase, state?: string, stateStyle?: string): Promise { + 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: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + const state = options?.state; + const stateStyle = options?.stateStyle; + return new ResourceNotificationServicePromise(this._publishResourceUpdateInternal(resource, state, stateStyle)); + } + +} + +/** + * Thenable wrapper for ResourceNotificationService that enables fluent chaining. + */ +export class ResourceNotificationServicePromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ResourceNotificationService) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Waits for a resource to reach a specified state */ + waitForResourceState(resourceName: string, options?: WaitForResourceStateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForResourceState(resourceName, options))); + } + + /** Waits for a resource to reach one of the specified states */ + waitForResourceStates(resourceName: string, targetStates: string[]): Promise { + return this._promise.then(obj => obj.waitForResourceStates(resourceName, targetStates)); + } + + /** Waits for a resource to become healthy */ + waitForResourceHealthy(resourceName: string): Promise { + return this._promise.then(obj => obj.waitForResourceHealthy(resourceName)); + } + + /** Waits for all dependencies of a resource to be ready */ + waitForDependencies(resource: ResourceBuilderBase): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.waitForDependencies(resource))); + } + + /** Tries to get the current state of a resource */ + tryGetResourceState(resourceName: string): Promise { + return this._promise.then(obj => obj.tryGetResourceState(resourceName)); + } + + /** Publishes an update for a resource's state */ + publishResourceUpdate(resource: ResourceBuilderBase, options?: PublishResourceUpdateOptions): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.publishResourceUpdate(resource, options))); + } + +} + +// ============================================================================ +// ResourceReadyEvent +// ============================================================================ + +/** + * Type class for ResourceReadyEvent. + */ +export class ResourceReadyEvent { + constructor(private _handle: ResourceReadyEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceReadyEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// ResourceStoppedEvent +// ============================================================================ + +/** + * Type class for ResourceStoppedEvent. + */ +export class ResourceStoppedEvent { + constructor(private _handle: ResourceStoppedEventHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + + /** Gets the Services property */ + services = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceStoppedEvent.services', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + // ============================================================================ // ResourceUrlsCallbackContext // ============================================================================ @@ -1834,6 +2976,17 @@ export class ResourceUrlsCallbackContext { /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } + /** Gets the Resource property */ + resource = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.resource', + { context: this._handle } + ); + return new Resource(handle, this._client); + }, + }; + /** Gets the Urls property */ private _urls?: AspireList; get urls(): AspireList { @@ -1850,11 +3003,23 @@ export class ResourceUrlsCallbackContext { /** Gets the CancellationToken property */ cancellationToken = { - get: async (): Promise => { - return await this._client.invokeCapability( + get: async (): Promise => { + const result = await this._client.invokeCapability( 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.cancellationToken', { context: this._handle } ); + return CancellationToken.fromValue(result); + }, + }; + + /** Gets the Logger property */ + logger = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/ResourceUrlsCallbackContext.logger', + { context: this._handle } + ); + return new Logger(handle, this._client); }, }; @@ -1871,6 +3036,132 @@ export class ResourceUrlsCallbackContext { } +// ============================================================================ +// UpdateCommandStateContext +// ============================================================================ + +/** + * Type class for UpdateCommandStateContext. + */ +export class UpdateCommandStateContext { + constructor(private _handle: UpdateCommandStateContextHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets the ServiceProvider property */ + serviceProvider = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/UpdateCommandStateContext.serviceProvider', + { context: this._handle } + ); + return new ServiceProvider(handle, this._client); + }, + }; + +} + +// ============================================================================ +// Configuration +// ============================================================================ + +/** + * Type class for Configuration. + */ +export class Configuration { + constructor(private _handle: IConfigurationHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Gets a configuration value by key */ + async getConfigValue(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConfigValue', + rpcArgs + ); + } + + /** Gets a connection string by name */ + async getConnectionString(name: string): Promise { + const rpcArgs: Record = { configuration: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionString', + rpcArgs + ); + } + + /** Gets a configuration section by key */ + async getSection(key: string): Promise { + const rpcArgs: Record = { configuration: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getSection', + rpcArgs + ); + } + + /** Gets child configuration sections */ + async getChildren(): Promise { + const rpcArgs: Record = { configuration: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getChildren', + rpcArgs + ); + } + + /** Checks whether a configuration section exists */ + 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. + */ +export class ConfigurationPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Configuration) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Gets a configuration value by key */ + getConfigValue(key: string): Promise { + return this._promise.then(obj => obj.getConfigValue(key)); + } + + /** Gets a connection string by name */ + getConnectionString(name: string): Promise { + return this._promise.then(obj => obj.getConnectionString(name)); + } + + /** Gets a configuration section by key */ + getSection(key: string): Promise { + return this._promise.then(obj => obj.getSection(key)); + } + + /** Gets child configuration sections */ + getChildren(): Promise { + return this._promise.then(obj => obj.getChildren()); + } + + /** Checks whether a configuration section exists */ + exists(key: string): Promise { + return this._promise.then(obj => obj.exists(key)); + } + +} + // ============================================================================ // DistributedApplicationBuilder // ============================================================================ @@ -1894,6 +3185,17 @@ export class DistributedApplicationBuilder { }, }; + /** Gets the Environment property */ + environment = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.environment', + { context: this._handle } + ); + return new HostEnvironment(handle, this._client); + }, + }; + /** Gets the Eventing property */ eventing = { get: async (): Promise => { @@ -1916,6 +3218,17 @@ export class DistributedApplicationBuilder { }, }; + /** Gets the UserSecretsManager property */ + userSecretsManager = { + get: async (): Promise => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting/IDistributedApplicationBuilder.userSecretsManager', + { context: this._handle } + ); + return new UserSecretsManager(handle, this._client); + }, + }; + /** Builds the distributed application */ /** @internal */ async _buildInternal(): Promise { @@ -1931,6 +3244,21 @@ export class DistributedApplicationBuilder { return new DistributedApplicationPromise(this._buildInternal()); } + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + /** Adds a connection string with a builder callback */ /** @internal */ async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { @@ -1968,19 +3296,36 @@ export class DistributedApplicationBuilder { return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); } - /** Adds a container resource */ + /** Adds a container registry with string endpoint */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, image }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addContainer', + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', rpcArgs ); - return new ContainerResource(result, this._client); + return new ContainerRegistryResource(result, this._client); } - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._addContainerInternal(name, image)); + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + + /** Adds a container resource */ + /** @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 ContainerResource(result, this._client); + } + + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._addContainerInternal(name, image)); } /** Adds a container resource built from a Dockerfile */ @@ -2047,6 +3392,36 @@ export class DistributedApplicationBuilder { return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); } + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + /** Adds a parameter resource */ /** @internal */ async _addParameterInternal(name: string, secret?: boolean): Promise { @@ -2064,6 +3439,25 @@ export class DistributedApplicationBuilder { return new ParameterResourcePromise(this._addParameterInternal(name, secret)); } + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + /** Adds a parameter sourced from configuration */ /** @internal */ async _addParameterFromConfigurationInternal(name: string, configurationKey: string, secret?: boolean): Promise { @@ -2081,6 +3475,25 @@ export class DistributedApplicationBuilder { return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); } + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + /** Adds a connection string resource */ /** @internal */ async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { @@ -2098,6 +3511,21 @@ export class DistributedApplicationBuilder { return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); } + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + /** Adds a .NET project resource */ /** @internal */ async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { @@ -2129,468 +3557,1369 @@ export class DistributedApplicationBuilder { return new ProjectResource(result, this._client); } - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithOptionsInternal(name, projectPath, configure)); + } + + /** Adds a C# application resource */ + /** @internal */ + async _addCSharpAppInternal(name: string, path: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, path }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpApp', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + } + + /** Adds a C# application resource with configuration options */ + /** @internal */ + async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; + const obj = new ProjectResourceOptions(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addCSharpAppWithOptions', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + } + + /** Gets the application configuration */ + /** @internal */ + async _getConfigurationInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getConfiguration', + rpcArgs + ); + return new Configuration(result, this._client); + } + + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._getConfigurationInternal()); + } + + /** Subscribes to the BeforeStart event */ + async subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeStartEventHandle; + const arg = new BeforeStartEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeBeforeStart', + rpcArgs + ); + } + + /** Subscribes to the AfterResourcesCreated event */ + async subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as AfterResourcesCreatedEventHandle; + const arg = new AfterResourcesCreatedEvent(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + return await this._client.invokeCapability( + 'Aspire.Hosting/subscribeAfterResourcesCreated', + rpcArgs + ); + } + + /** Adds a Microsoft Foundry resource to the distributed application model. */ + /** @internal */ + async _addFoundryInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/addFoundry', + rpcArgs + ); + return new FoundryResource(result, this._client); + } + + addFoundry(name: string): FoundryResourcePromise { + return new FoundryResourcePromise(this._addFoundryInternal(name)); + } + + /** Adds an Azure Bicep template resource from a file */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + /** @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 AzureBicepResource(result, this._client); + } + + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + } + + /** Adds an Azure provisioning resource to the application model */ + /** @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 AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + } + + /** Adds Azure provisioning services to the distributed application builder */ + /** @internal */ + async _addAzureProvisioningInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureProvisioning', + rpcArgs + ); + return new DistributedApplicationBuilder(result, this._client); + } + + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + } + + /** Adds the shared Azure environment resource to the application model */ + /** @internal */ + async _addAzureEnvironmentInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/addAzureEnvironment', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + } + + /** Adds an Azure user-assigned identity resource */ + /** @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 AzureUserAssignedIdentityResource(result, this._client); + } + + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); + } + + /** Adds an Azure Application Insights resource */ + /** @internal */ + async _addAzureApplicationInsightsInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.ApplicationInsights/addAzureApplicationInsights', + rpcArgs + ); + return new AzureApplicationInsightsResource(result, this._client); + } + + addAzureApplicationInsights(name: string): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._addAzureApplicationInsightsInternal(name)); + } + + /** Adds an Azure Container Registry resource to the distributed application model. */ + /** @internal */ + async _addAzureContainerRegistryInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.ContainerRegistry/addAzureContainerRegistry', + rpcArgs + ); + return new AzureContainerRegistryResource(result, this._client); + } + + addAzureContainerRegistry(name: string): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._addAzureContainerRegistryInternal(name)); + } + + /** Adds an Azure Cosmos DB resource */ + /** @internal */ + async _addAzureCosmosDBInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.CosmosDB/addAzureCosmosDB', + rpcArgs + ); + return new AzureCosmosDBResource(result, this._client); + } + + addAzureCosmosDB(name: string): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._addAzureCosmosDBInternal(name)); + } + + /** Adds an Azure Key Vault resource */ + /** @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 AzureKeyVaultResource(result, this._client); + } + + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._addAzureKeyVaultInternal(name)); + } + + /** Adds an Azure Log Analytics Workspace resource */ + /** @internal */ + async _addAzureLogAnalyticsWorkspaceInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.OperationalInsights/addAzureLogAnalyticsWorkspace', + rpcArgs + ); + return new AzureLogAnalyticsWorkspaceResource(result, this._client); + } + + addAzureLogAnalyticsWorkspace(name: string): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._addAzureLogAnalyticsWorkspaceInternal(name)); + } + + /** Adds an Azure AI Search service resource */ + /** @internal */ + async _addAzureSearchInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Search/addAzureSearch', + rpcArgs + ); + return new AzureSearchResource(result, this._client); + } + + addAzureSearch(name: string): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._addAzureSearchInternal(name)); + } + + /** Adds an Azure Storage resource */ + /** @internal */ + async _addAzureStorageInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure.Storage/addAzureStorage', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + addAzureStorage(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._addAzureStorageInternal(name)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + */ +export class DistributedApplicationBuilderPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Builds the distributed application */ + build(): DistributedApplicationPromise { + return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + } + + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + + /** Adds a connection string with a builder callback */ + addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + } + + /** Adds a container registry resource */ + addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + } + + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + + /** Adds a container resource */ + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + } + + /** Adds a container resource built from a Dockerfile */ + addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); + } + + /** Adds a .NET tool resource */ + addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); + } + + /** Adds an executable resource */ + addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); + } + + /** Adds an external service resource */ + addExternalService(name: string, url: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); + } + + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + + /** Adds a parameter resource */ + addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + } + + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + + /** Adds a parameter sourced from configuration */ + addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + } + + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + + /** Adds a connection string resource */ + addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + } + + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + + /** Adds a .NET project resource */ + addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + } + + /** Adds a project resource with configuration options */ + addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + } + + /** Adds a C# application resource */ + addCSharpApp(name: string, path: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + } + + /** Adds a C# application resource with configuration options */ + addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + } + + /** Gets the application configuration */ + getConfiguration(): ConfigurationPromise { + return new ConfigurationPromise(this._promise.then(obj => obj.getConfiguration())); + } + + /** Subscribes to the BeforeStart event */ + subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeBeforeStart(callback)); + } + + /** Subscribes to the AfterResourcesCreated event */ + subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise): Promise { + return this._promise.then(obj => obj.subscribeAfterResourcesCreated(callback)); + } + + /** Adds a Microsoft Foundry resource to the distributed application model. */ + addFoundry(name: string): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.addFoundry(name))); + } + + /** Adds an Azure Bicep template resource from a file */ + addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + } + + /** Adds an Azure Bicep template resource from inline Bicep content */ + addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + } + + /** Adds an Azure provisioning resource to the application model */ + addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + } + + /** Adds Azure provisioning services to the distributed application builder */ + addAzureProvisioning(): DistributedApplicationBuilderPromise { + return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + } + + /** Adds the shared Azure environment resource to the application model */ + addAzureEnvironment(): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); + } + + /** Adds an Azure user-assigned identity resource */ + addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); + } + + /** Adds an Azure Application Insights resource */ + addAzureApplicationInsights(name: string): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.addAzureApplicationInsights(name))); + } + + /** Adds an Azure Container Registry resource to the distributed application model. */ + addAzureContainerRegistry(name: string): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.addAzureContainerRegistry(name))); + } + + /** Adds an Azure Cosmos DB resource */ + addAzureCosmosDB(name: string): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.addAzureCosmosDB(name))); + } + + /** Adds an Azure Key Vault resource */ + addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.addAzureKeyVault(name))); + } + + /** Adds an Azure Log Analytics Workspace resource */ + addAzureLogAnalyticsWorkspace(name: string): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.addAzureLogAnalyticsWorkspace(name))); + } + + /** Adds an Azure AI Search service resource */ + addAzureSearch(name: string): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.addAzureSearch(name))); + } + + /** Adds an Azure Storage resource */ + addAzureStorage(name: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.addAzureStorage(name))); + } + +} + +// ============================================================================ +// DistributedApplicationEventing +// ============================================================================ + +/** + * Type class for DistributedApplicationEventing. + */ +export class DistributedApplicationEventing { + constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Invokes the Unsubscribe method */ + /** @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 DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + } + +} + +/** + * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + */ +export class DistributedApplicationEventingPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Invokes the Unsubscribe method */ + unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + } + +} + +// ============================================================================ +// HostEnvironment +// ============================================================================ + +/** + * Type class for HostEnvironment. + */ +export class HostEnvironment { + constructor(private _handle: IHostEnvironmentHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Checks if running in Development environment */ + async isDevelopment(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isDevelopment', + rpcArgs + ); + } + + /** Checks if running in Production environment */ + async isProduction(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isProduction', + rpcArgs + ); + } + + /** Checks if running in Staging environment */ + async isStaging(): Promise { + const rpcArgs: Record = { environment: this._handle }; + return await this._client.invokeCapability( + 'Aspire.Hosting/isStaging', + rpcArgs + ); + } + + /** Checks if the environment matches the specified name */ + 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. + */ +export class HostEnvironmentPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: HostEnvironment) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Checks if running in Development environment */ + isDevelopment(): Promise { + return this._promise.then(obj => obj.isDevelopment()); + } + + /** Checks if running in Production environment */ + isProduction(): Promise { + return this._promise.then(obj => obj.isProduction()); + } + + /** Checks if running in Staging environment */ + isStaging(): Promise { + return this._promise.then(obj => obj.isStaging()); + } + + /** Checks if the environment matches the specified name */ + isEnvironment(environmentName: string): Promise { + return this._promise.then(obj => obj.isEnvironment(environmentName)); + } + +} + +// ============================================================================ +// Logger +// ============================================================================ + +/** + * Type class for Logger. + */ +export class Logger { + constructor(private _handle: ILoggerHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Logs an information message */ + /** @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 LoggerPromise(this._logInformationInternal(message)); + } + + /** Logs a warning message */ + /** @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 LoggerPromise(this._logWarningInternal(message)); + } + + /** Logs an error message */ + /** @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 LoggerPromise(this._logErrorInternal(message)); + } + + /** Logs a debug message */ + /** @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 LoggerPromise(this._logDebugInternal(message)); + } + + /** Logs a message with specified level */ + /** @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 LoggerPromise(this._logInternal(level, message)); + } + +} + +/** + * Thenable wrapper for Logger that enables fluent chaining. + */ +export class LoggerPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: Logger) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); + } + + /** Logs an information message */ + logInformation(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logInformation(message))); + } + + /** Logs a warning message */ + logWarning(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logWarning(message))); + } + + /** Logs an error message */ + logError(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logError(message))); + } + + /** Logs a debug message */ + logDebug(message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.logDebug(message))); + } + + /** Logs a message with specified level */ + log(level: string, message: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.log(level, message))); } - /** Adds a C# application resource */ +} + +// ============================================================================ +// LoggerFactory +// ============================================================================ + +/** + * Type class for LoggerFactory. + */ +export class LoggerFactory { + constructor(private _handle: ILoggerFactoryHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a logger for a category */ /** @internal */ - async _addCSharpAppInternal(name: string, path: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, path }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpApp', + async _createLoggerInternal(categoryName: string): Promise { + const rpcArgs: Record = { loggerFactory: this._handle, categoryName }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/createLogger', rpcArgs ); - return new ProjectResource(result, this._client); + return new Logger(result, this._client); } - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._addCSharpAppInternal(name, path)); + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._createLoggerInternal(categoryName)); } - /** Adds a C# application resource with configuration options */ - /** @internal */ - async _addCSharpAppWithOptionsInternal(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): Promise { - const configureId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as ProjectResourceOptionsHandle; - const obj = new ProjectResourceOptions(objHandle, this._client); - await configure(obj); - }); - const rpcArgs: Record = { builder: this._handle, name, path, configure: configureId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/addCSharpAppWithOptions', - rpcArgs - ); - return new CSharpAppResource(result, this._client); +} + +/** + * Thenable wrapper for LoggerFactory that enables fluent chaining. + */ +export class LoggerFactoryPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: LoggerFactory) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._addCSharpAppWithOptionsInternal(name, path, configure)); + /** Creates a logger for a category */ + createLogger(categoryName: string): LoggerPromise { + return new LoggerPromise(this._promise.then(obj => obj.createLogger(categoryName))); } - /** Adds a Microsoft Foundry resource to the distributed application model. */ +} + +// ============================================================================ +// ReportingStep +// ============================================================================ + +/** + * Type class for ReportingStep. + */ +export class ReportingStep { + constructor(private _handle: IReportingStepHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Creates a reporting task with plain-text status text */ /** @internal */ - async _addFoundryInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/addFoundry', + 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 FoundryResource(result, this._client); + return new ReportingTask(result, this._client); } - addFoundry(name: string): FoundryResourcePromise { - return new FoundryResourcePromise(this._addFoundryInternal(name)); + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createTaskInternal(statusText, cancellationToken)); } - /** Adds an Azure Bicep template resource from a file */ + /** Creates a reporting task with Markdown-formatted status text */ /** @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', + 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 AzureBicepResource(result, this._client); + return new ReportingTask(result, this._client); } - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateInternal(name, bicepFile)); + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._createMarkdownTaskInternal(markdownString, cancellationToken)); } - /** Adds an Azure Bicep template resource from inline Bicep content */ + /** Logs a plain-text message for the reporting step */ /** @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', + async _logStepInternal(level: string, message: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, message }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStep', rpcArgs ); - return new AzureBicepResource(result, this._client); + return this; } - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._addBicepTemplateStringInternal(name, bicepContent)); + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepInternal(level, message)); } - /** Adds an Azure provisioning resource to the application model */ + /** Logs a Markdown-formatted message for the reporting step */ /** @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 AzureResourceInfrastructure(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', + async _logStepMarkdownInternal(level: string, markdownString: string): Promise { + const rpcArgs: Record = { reportingStep: this._handle, level, markdownString }; + await this._client.invokeCapability( + 'Aspire.Hosting/logStepMarkdown', rpcArgs ); - return new AzureProvisioningResource(result, this._client); + return this; } - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._addAzureInfrastructureInternal(name, configureInfrastructure)); + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._logStepMarkdownInternal(level, markdownString)); } - /** Adds Azure provisioning services to the distributed application builder */ + /** Completes the reporting step with plain-text completion text */ /** @internal */ - async _addAzureProvisioningInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureProvisioning', + 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 new DistributedApplicationBuilder(result, this._client); + return this; } - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._addAzureProvisioningInternal()); + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepInternal(completionText, completionState, cancellationToken)); } - /** Adds the shared Azure environment resource to the application model */ + /** Completes the reporting step with Markdown-formatted completion text */ /** @internal */ - async _addAzureEnvironmentInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/addAzureEnvironment', + 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 new AzureEnvironmentResource(result, this._client); + return this; } - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._addAzureEnvironmentInternal()); + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingStepPromise(this._completeStepMarkdownInternal(markdownString, completionState, cancellationToken)); } - /** Adds an Azure user-assigned identity resource */ - /** @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 AzureUserAssignedIdentityResource(result, this._client); - } +} - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._addAzureUserAssignedIdentityInternal(name)); +/** + * Thenable wrapper for ReportingStep that enables fluent chaining. + */ +export class ReportingStepPromise implements PromiseLike { + constructor(private _promise: Promise) {} + + then( + onfulfilled?: ((value: ReportingStep) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds an Azure Application Insights resource */ - /** @internal */ - async _addAzureApplicationInsightsInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.ApplicationInsights/addAzureApplicationInsights', - rpcArgs - ); - return new AzureApplicationInsightsResource(result, this._client); + /** Creates a reporting task with plain-text status text */ + createTask(statusText: string, options?: CreateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createTask(statusText, options))); } - addAzureApplicationInsights(name: string): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._addAzureApplicationInsightsInternal(name)); + /** Creates a reporting task with Markdown-formatted status text */ + createMarkdownTask(markdownString: string, options?: CreateMarkdownTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.createMarkdownTask(markdownString, options))); } - /** Adds an Azure Container Registry resource to the distributed application model. */ - /** @internal */ - async _addAzureContainerRegistryInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.ContainerRegistry/addAzureContainerRegistry', - rpcArgs - ); - return new AzureContainerRegistryResource(result, this._client); + /** Logs a plain-text message for the reporting step */ + logStep(level: string, message: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStep(level, message))); } - addAzureContainerRegistry(name: string): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._addAzureContainerRegistryInternal(name)); + /** Logs a Markdown-formatted message for the reporting step */ + logStepMarkdown(level: string, markdownString: string): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.logStepMarkdown(level, markdownString))); } - /** Adds an Azure Cosmos DB resource */ - /** @internal */ - async _addAzureCosmosDBInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.CosmosDB/addAzureCosmosDB', - rpcArgs - ); - return new AzureCosmosDBResource(result, this._client); + /** Completes the reporting step with plain-text completion text */ + completeStep(completionText: string, options?: CompleteStepOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStep(completionText, options))); } - addAzureCosmosDB(name: string): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._addAzureCosmosDBInternal(name)); + /** Completes the reporting step with Markdown-formatted completion text */ + completeStepMarkdown(markdownString: string, options?: CompleteStepMarkdownOptions): ReportingStepPromise { + return new ReportingStepPromise(this._promise.then(obj => obj.completeStepMarkdown(markdownString, options))); } - /** Adds an Azure Key Vault resource */ +} + +// ============================================================================ +// ReportingTask +// ============================================================================ + +/** + * Type class for ReportingTask. + */ +export class ReportingTask { + constructor(private _handle: IReportingTaskHandle, private _client: AspireClientRpc) {} + + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } + + /** Updates the reporting task with plain-text status text */ /** @internal */ - async _addAzureKeyVaultInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.KeyVault/addAzureKeyVault', + 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 new AzureKeyVaultResource(result, this._client); + return this; } - addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._addAzureKeyVaultInternal(name)); + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskInternal(statusText, cancellationToken)); } - /** Adds an Azure Log Analytics Workspace resource */ + /** Updates the reporting task with Markdown-formatted status text */ /** @internal */ - async _addAzureLogAnalyticsWorkspaceInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.OperationalInsights/addAzureLogAnalyticsWorkspace', + 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 new AzureLogAnalyticsWorkspaceResource(result, this._client); + return this; } - addAzureLogAnalyticsWorkspace(name: string): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._addAzureLogAnalyticsWorkspaceInternal(name)); + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._updateTaskMarkdownInternal(markdownString, cancellationToken)); } - /** Adds an Azure AI Search service resource */ + /** Completes the reporting task with plain-text completion text */ /** @internal */ - async _addAzureSearchInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Search/addAzureSearch', + 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 new AzureSearchResource(result, this._client); + return this; } - addAzureSearch(name: string): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._addAzureSearchInternal(name)); + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + const completionMessage = options?.completionMessage; + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskInternal(completionMessage, completionState, cancellationToken)); } - /** Adds an Azure Storage resource */ + /** Completes the reporting task with Markdown-formatted completion text */ /** @internal */ - async _addAzureStorageInternal(name: string): Promise { - const rpcArgs: Record = { builder: this._handle, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure.Storage/addAzureStorage', + 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 new AzureStorageResource(result, this._client); + return this; } - addAzureStorage(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._addAzureStorageInternal(name)); + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + const completionState = options?.completionState; + const cancellationToken = options?.cancellationToken; + return new ReportingTaskPromise(this._completeTaskMarkdownInternal(markdownString, completionState, cancellationToken)); } } /** - * Thenable wrapper for DistributedApplicationBuilder that enables fluent chaining. + * Thenable wrapper for ReportingTask that enables fluent chaining. */ -export class DistributedApplicationBuilderPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class ReportingTaskPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationBuilder) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: ReportingTask) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Builds the distributed application */ - build(): DistributedApplicationPromise { - return new DistributedApplicationPromise(this._promise.then(obj => obj.build())); + /** Updates the reporting task with plain-text status text */ + updateTask(statusText: string, options?: UpdateTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTask(statusText, options))); } - /** Adds a connection string with a builder callback */ - addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { - return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); + /** Updates the reporting task with Markdown-formatted status text */ + updateTaskMarkdown(markdownString: string, options?: UpdateTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.updateTaskMarkdown(markdownString, options))); } - /** Adds a container registry resource */ - addContainerRegistry(name: string, endpoint: ParameterResource, options?: AddContainerRegistryOptions): ContainerRegistryResourcePromise { - return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistry(name, endpoint, options))); + /** Completes the reporting task with plain-text completion text */ + completeTask(options?: CompleteTaskOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTask(options))); } - /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); + /** Completes the reporting task with Markdown-formatted completion text */ + completeTaskMarkdown(markdownString: string, options?: CompleteTaskMarkdownOptions): ReportingTaskPromise { + return new ReportingTaskPromise(this._promise.then(obj => obj.completeTaskMarkdown(markdownString, options))); } - /** Adds a container resource built from a Dockerfile */ - addDockerfile(name: string, contextPath: string, options?: AddDockerfileOptions): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.addDockerfile(name, contextPath, options))); - } +} - /** Adds a .NET tool resource */ - addDotnetTool(name: string, packageId: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.addDotnetTool(name, packageId))); - } +// ============================================================================ +// ServiceProvider +// ============================================================================ - /** Adds an executable resource */ - addExecutable(name: string, command: string, workingDirectory: string, args: string[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.addExecutable(name, command, workingDirectory, args))); - } +/** + * Type class for ServiceProvider. + */ +export class ServiceProvider { + constructor(private _handle: IServiceProviderHandle, private _client: AspireClientRpc) {} - /** Adds an external service resource */ - addExternalService(name: string, url: string): ExternalServiceResourcePromise { - return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalService(name, url))); - } + /** Serialize for JSON-RPC transport */ + toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Adds a parameter resource */ - addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); + /** Gets the distributed application eventing service from the service provider */ + /** @internal */ + async _getEventingInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getEventing', + rpcArgs + ); + return new DistributedApplicationEventing(result, this._client); } - /** Adds a parameter sourced from configuration */ - addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { - return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._getEventingInternal()); } - /** Adds a connection string resource */ - addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { - return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); + /** Gets the logger factory from the service provider */ + /** @internal */ + async _getLoggerFactoryInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getLoggerFactory', + rpcArgs + ); + return new LoggerFactory(result, this._client); } - /** Adds a .NET project resource */ - addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._getLoggerFactoryInternal()); } - /** Adds a project resource with configuration options */ - addProjectWithOptions(name: string, projectPath: string, configure: (obj: ProjectResourceOptions) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithOptions(name, projectPath, configure))); + /** Gets the resource logger service from the service provider */ + /** @internal */ + async _getResourceLoggerServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceLoggerService', + rpcArgs + ); + return new ResourceLoggerService(result, this._client); } - /** Adds a C# application resource */ - addCSharpApp(name: string, path: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.addCSharpApp(name, path))); + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._getResourceLoggerServiceInternal()); } - /** Adds a C# application resource with configuration options */ - addCSharpAppWithOptions(name: string, path: string, configure: (obj: ProjectResourceOptions) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.addCSharpAppWithOptions(name, path, configure))); + /** Gets the distributed application model from the service provider */ + /** @internal */ + async _getDistributedApplicationModelInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getDistributedApplicationModel', + rpcArgs + ); + return new DistributedApplicationModel(result, this._client); } - /** Adds a Microsoft Foundry resource to the distributed application model. */ - addFoundry(name: string): FoundryResourcePromise { - return new FoundryResourcePromise(this._promise.then(obj => obj.addFoundry(name))); + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._getDistributedApplicationModelInternal()); } - /** Adds an Azure Bicep template resource from a file */ - addBicepTemplate(name: string, bicepFile: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplate(name, bicepFile))); + /** Gets the resource notification service from the service provider */ + /** @internal */ + async _getResourceNotificationServiceInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getResourceNotificationService', + rpcArgs + ); + return new ResourceNotificationService(result, this._client); } - /** Adds an Azure Bicep template resource from inline Bicep content */ - addBicepTemplateString(name: string, bicepContent: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.addBicepTemplateString(name, bicepContent))); + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._getResourceNotificationServiceInternal()); } - /** Adds an Azure provisioning resource to the application model */ - addAzureInfrastructure(name: string, configureInfrastructure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.addAzureInfrastructure(name, configureInfrastructure))); + /** Gets the user secrets manager from the service provider */ + /** @internal */ + async _getUserSecretsManagerInternal(): Promise { + const rpcArgs: Record = { serviceProvider: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/getUserSecretsManager', + rpcArgs + ); + return new UserSecretsManager(result, this._client); } - /** Adds Azure provisioning services to the distributed application builder */ - addAzureProvisioning(): DistributedApplicationBuilderPromise { - return new DistributedApplicationBuilderPromise(this._promise.then(obj => obj.addAzureProvisioning())); + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getUserSecretsManagerInternal()); } - /** Adds the shared Azure environment resource to the application model */ - addAzureEnvironment(): AzureEnvironmentResourcePromise { - return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.addAzureEnvironment())); - } +} - /** Adds an Azure user-assigned identity resource */ - addAzureUserAssignedIdentity(name: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.addAzureUserAssignedIdentity(name))); - } +/** + * Thenable wrapper for ServiceProvider that enables fluent chaining. + */ +export class ServiceProviderPromise implements PromiseLike { + constructor(private _promise: Promise) {} - /** Adds an Azure Application Insights resource */ - addAzureApplicationInsights(name: string): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.addAzureApplicationInsights(name))); + then( + onfulfilled?: ((value: ServiceProvider) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): PromiseLike { + return this._promise.then(onfulfilled, onrejected); } - /** Adds an Azure Container Registry resource to the distributed application model. */ - addAzureContainerRegistry(name: string): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.addAzureContainerRegistry(name))); + /** Gets the distributed application eventing service from the service provider */ + getEventing(): DistributedApplicationEventingPromise { + return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.getEventing())); } - /** Adds an Azure Cosmos DB resource */ - addAzureCosmosDB(name: string): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.addAzureCosmosDB(name))); + /** Gets the logger factory from the service provider */ + getLoggerFactory(): LoggerFactoryPromise { + return new LoggerFactoryPromise(this._promise.then(obj => obj.getLoggerFactory())); } - /** Adds an Azure Key Vault resource */ - addAzureKeyVault(name: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.addAzureKeyVault(name))); + /** Gets the resource logger service from the service provider */ + getResourceLoggerService(): ResourceLoggerServicePromise { + return new ResourceLoggerServicePromise(this._promise.then(obj => obj.getResourceLoggerService())); } - /** Adds an Azure Log Analytics Workspace resource */ - addAzureLogAnalyticsWorkspace(name: string): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.addAzureLogAnalyticsWorkspace(name))); + /** Gets the distributed application model from the service provider */ + getDistributedApplicationModel(): DistributedApplicationModelPromise { + return new DistributedApplicationModelPromise(this._promise.then(obj => obj.getDistributedApplicationModel())); } - /** Adds an Azure AI Search service resource */ - addAzureSearch(name: string): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._promise.then(obj => obj.addAzureSearch(name))); + /** Gets the resource notification service from the service provider */ + getResourceNotificationService(): ResourceNotificationServicePromise { + return new ResourceNotificationServicePromise(this._promise.then(obj => obj.getResourceNotificationService())); } - /** Adds an Azure Storage resource */ - addAzureStorage(name: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.addAzureStorage(name))); + /** Gets the user secrets manager from the service provider */ + getUserSecretsManager(): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getUserSecretsManager())); } } // ============================================================================ -// DistributedApplicationEventing +// UserSecretsManager // ============================================================================ /** - * Type class for DistributedApplicationEventing. + * Type class for UserSecretsManager. */ -export class DistributedApplicationEventing { - constructor(private _handle: IDistributedApplicationEventingHandle, private _client: AspireClientRpc) {} +export class UserSecretsManager { + constructor(private _handle: IUserSecretsManagerHandle, private _client: AspireClientRpc) {} /** Serialize for JSON-RPC transport */ toJSON(): MarshalledHandle { return this._handle.toJSON(); } - /** Invokes the Unsubscribe method */ + /** Gets the IsAvailable property */ + isAvailable = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.isAvailable', + { context: this._handle } + ); + }, + }; + + /** Gets the FilePath property */ + filePath = { + get: async (): Promise => { + return await this._client.invokeCapability( + 'Aspire.Hosting/IUserSecretsManager.filePath', + { context: this._handle } + ); + }, + }; + + /** Attempts to set a user secret value */ + 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 + ); + } + + /** Saves state to user secrets from a JSON string */ /** @internal */ - async _unsubscribeInternal(subscription: DistributedApplicationEventSubscriptionHandle): Promise { - const rpcArgs: Record = { context: this._handle, subscription }; + 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.Eventing/IDistributedApplicationEventing.unsubscribe', + 'Aspire.Hosting/saveStateJson', rpcArgs ); return this; } - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._unsubscribeInternal(subscription)); + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + const cancellationToken = options?.cancellationToken; + return new UserSecretsManagerPromise(this._saveStateJsonInternal(json, cancellationToken)); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + /** @internal */ + async _getOrSetSecretInternal(resourceBuilder: ResourceBuilderBase, name: string, value: string): Promise { + const rpcArgs: Record = { userSecretsManager: this._handle, resourceBuilder, name, value }; + await this._client.invokeCapability( + 'Aspire.Hosting/getOrSetSecret', + rpcArgs + ); + return this; + } + + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._getOrSetSecretInternal(resourceBuilder, name, value)); } } /** - * Thenable wrapper for DistributedApplicationEventing that enables fluent chaining. + * Thenable wrapper for UserSecretsManager that enables fluent chaining. */ -export class DistributedApplicationEventingPromise implements PromiseLike { - constructor(private _promise: Promise) {} +export class UserSecretsManagerPromise implements PromiseLike { + constructor(private _promise: Promise) {} - then( - onfulfilled?: ((value: DistributedApplicationEventing) => TResult1 | PromiseLike) | null, + then( + onfulfilled?: ((value: UserSecretsManager) => TResult1 | PromiseLike) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null ): PromiseLike { return this._promise.then(onfulfilled, onrejected); } - /** Invokes the Unsubscribe method */ - unsubscribe(subscription: DistributedApplicationEventSubscriptionHandle): DistributedApplicationEventingPromise { - return new DistributedApplicationEventingPromise(this._promise.then(obj => obj.unsubscribe(subscription))); + /** Attempts to set a user secret value */ + trySetSecret(name: string, value: string): Promise { + return this._promise.then(obj => obj.trySetSecret(name, value)); + } + + /** Saves state to user secrets from a JSON string */ + saveStateJson(json: string, options?: SaveStateJsonOptions): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.saveStateJson(json, options))); + } + + /** Gets a secret value if it exists, or sets it to the provided value if it does not */ + getOrSetSecret(resourceBuilder: ResourceBuilderBase, name: string, value: string): UserSecretsManagerPromise { + return new UserSecretsManagerPromise(this._promise.then(obj => obj.getOrSetSecret(resourceBuilder, name, value))); } } @@ -2641,7 +4970,7 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase { + 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', @@ -2650,8 +4979,8 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -2830,11 +5168,26 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureApplicationInsightsResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureApplicationInsightsResource(result, this._client); @@ -2849,7 +5202,7 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureApplicationInsightsResource(result, this._client); @@ -2969,6 +5322,106 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureApplicationInsightsResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureApplicationInsightsResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureApplicationInsightsResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureApplicationInsightsResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureApplicationInsightsResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -3182,23 +5635,9 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureApplicationInsightsResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -3207,28 +5646,15 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureApplicationInsightsResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -3237,23 +5663,26 @@ export class AzureApplicationInsightsResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureApplicationInsightsResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureApplicationInsightsResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureApplicationInsightsResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -3388,8 +5817,8 @@ export class AzureApplicationInsightsResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureApplicationInsightsResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureApplicationInsightsResourcePromise { return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -3398,6 +5827,11 @@ export class AzureApplicationInsightsResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureApplicationInsightsResourcePromise { return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -3443,6 +5877,11 @@ export class AzureApplicationInsightsResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureApplicationInsightsResourcePromise { return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -3483,6 +5922,31 @@ export class AzureApplicationInsightsResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureApplicationInsightsResourcePromise { return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -3558,29 +6022,19 @@ export class AzureApplicationInsightsResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureApplicationInsightsResourcePromise { - return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureApplicationInsightsResourcePromise { + return new AzureApplicationInsightsResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures the Application Insights resource to use a Log Analytics Workspace */ @@ -3825,11 +6279,26 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -3844,7 +6313,7 @@ export class AzureBicepResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBicepResource(result, this._client); @@ -3964,6 +6433,86 @@ export class AzureBicepResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBicepResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -3979,6 +6528,135 @@ export class AzureBicepResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name }; + return await this._client.invokeCapability( + 'Aspire.Hosting.Azure/getOutput', + rpcArgs + ); + } + + /** @internal */ + private async _withParameterInternal(name: string): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterInternal(name)); + } + + /** @internal */ + private async _withParameterStringValueInternal(name: string, value: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValue', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValueInternal(name, value)); + } + + /** @internal */ + private async _withParameterStringValuesInternal(name: string, value: string[]): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterStringValues', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterStringValuesInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromParameterInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromParameter', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromParameterInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromConnectionStringInternal(name: string, value: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromConnectionString', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromConnectionStringInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromOutputInternal(name: string, value: BicepOutputReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromOutput', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromOutputInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromReferenceExpressionInternal(name: string, value: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromReferenceExpression', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromReferenceExpressionInternal(name, value)); + } + + /** @internal */ + private async _withParameterFromEndpointInternal(name: string, value: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Azure/withParameterFromEndpoint', + rpcArgs + ); + return new AzureBicepResource(result, this._client); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._withParameterFromEndpointInternal(name, value)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -4028,23 +6706,9 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -4053,28 +6717,15 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureBicepResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -4083,23 +6734,26 @@ export class AzureBicepResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureBicepResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureBicepResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -4264,6 +6918,11 @@ export class AzureBicepResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4304,11 +6963,76 @@ export class AzureBicepResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); } + /** Gets an output reference from an Azure Bicep template resource */ + getOutput(name: string): Promise { + return this._promise.then(obj => obj.getOutput(name)); + } + + /** Adds a Bicep parameter without a value */ + withParameter(name: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameter(name))); + } + + /** Adds a Bicep parameter with a string value */ + withParameterStringValue(name: string, value: string): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValue(name, value))); + } + + /** Adds a Bicep parameter with a string list value */ + withParameterStringValues(name: string, value: string[]): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterStringValues(name, value))); + } + + /** Adds a Bicep parameter from a parameter resource builder */ + withParameterFromParameter(name: string, value: ParameterResource): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromParameter(name, value))); + } + + /** Adds a Bicep parameter from a connection string resource builder */ + withParameterFromConnectionString(name: string, value: ResourceBuilderBase): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromConnectionString(name, value))); + } + + /** Adds a Bicep parameter from another Bicep output reference */ + withParameterFromOutput(name: string, value: BicepOutputReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromOutput(name, value))); + } + + /** Adds a Bicep parameter from a reference expression */ + withParameterFromReferenceExpression(name: string, value: ReferenceExpression): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromReferenceExpression(name, value))); + } + + /** Adds a Bicep parameter from an endpoint reference */ + withParameterFromEndpoint(name: string, value: EndpointReference): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.withParameterFromEndpoint(name, value))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureBicepResourcePromise { return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -4329,29 +7053,19 @@ export class AzureBicepResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureBicepResourcePromise { - return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureBicepResourcePromise { + return new AzureBicepResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -4432,7 +7146,7 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + 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', @@ -4441,8 +7155,8 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -4621,11 +7344,26 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBlobStorageContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBlobStorageContainerResource(result, this._client); @@ -4640,7 +7378,7 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBlobStorageContainerResource(result, this._client); @@ -4760,6 +7498,106 @@ export class AzureBlobStorageContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBlobStorageContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -4892,8 +7730,8 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageContainerResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -4902,6 +7740,11 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -4947,6 +7790,11 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -4987,6 +7835,31 @@ export class AzureBlobStorageContainerResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageContainerResourcePromise { + return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureBlobStorageContainerResourcePromise { return new AzureBlobStorageContainerResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -5070,7 +7943,7 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { + 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', @@ -5079,8 +7952,8 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -5259,11 +8141,26 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureBlobStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureBlobStorageResource(result, this._client); @@ -5278,7 +8175,7 @@ export class AzureBlobStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureBlobStorageResource(result, this._client); @@ -5398,6 +8295,106 @@ export class AzureBlobStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureBlobStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -5530,8 +8527,8 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureBlobStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -5540,6 +8537,11 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -5585,6 +8587,11 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5625,6 +8632,31 @@ export class AzureBlobStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureBlobStorageResourcePromise { + return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureBlobStorageResourcePromise { return new AzureBlobStorageResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -5867,11 +8899,26 @@ export class AzureCognitiveServicesProjectConnectionResource extends ResourceBui return new AzureCognitiveServicesProjectConnectionResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureCognitiveServicesProjectConnectionResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureCognitiveServicesProjectConnectionResource(result, this._client); @@ -5886,7 +8933,7 @@ export class AzureCognitiveServicesProjectConnectionResource extends ResourceBui private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureCognitiveServicesProjectConnectionResource(result, this._client); @@ -6006,6 +9053,86 @@ export class AzureCognitiveServicesProjectConnectionResource extends ResourceBui ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureCognitiveServicesProjectConnectionResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureCognitiveServicesProjectConnectionResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureCognitiveServicesProjectConnectionResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureCognitiveServicesProjectConnectionResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -6219,23 +9346,9 @@ export class AzureCognitiveServicesProjectConnectionResource extends ResourceBui } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureCognitiveServicesProjectConnectionResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -6244,28 +9357,15 @@ export class AzureCognitiveServicesProjectConnectionResource extends ResourceBui } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureCognitiveServicesProjectConnectionResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureCognitiveServicesProjectConnectionResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureCognitiveServicesProjectConnectionResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureCognitiveServicesProjectConnectionResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -6274,23 +9374,26 @@ export class AzureCognitiveServicesProjectConnectionResource extends ResourceBui } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureCognitiveServicesProjectConnectionResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureCognitiveServicesProjectConnectionResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureCognitiveServicesProjectConnectionResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureCognitiveServicesProjectConnectionResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureCognitiveServicesProjectConnectionResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -6455,6 +9558,11 @@ export class AzureCognitiveServicesProjectConnectionResourcePromise implements P return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureCognitiveServicesProjectConnectionResourcePromise { return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6495,6 +9603,26 @@ export class AzureCognitiveServicesProjectConnectionResourcePromise implements P return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureCognitiveServicesProjectConnectionResourcePromise { return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -6570,29 +9698,19 @@ export class AzureCognitiveServicesProjectConnectionResourcePromise implements P return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectConnectionResourcePromise { - return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureCognitiveServicesProjectConnectionResourcePromise { + return new AzureCognitiveServicesProjectConnectionResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -6673,7 +9791,7 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { + 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', @@ -6682,8 +9800,8 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -6862,11 +9989,26 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureCognitiveServicesProjectResource(result, this._client); @@ -6881,7 +10023,7 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureCognitiveServicesProjectResource(result, this._client); @@ -7001,6 +10143,106 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -7136,6 +10378,36 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, name }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/addCapabilityHostProject', + rpcArgs + ); + return new AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Adds a capability host to a Microsoft Foundry project. */ + addCapabilityHost(name: string): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._addCapabilityHostInternal(name)); + } + + /** @internal */ + private async _withCapabilityHostInternal(resource: AzureCosmosDBResource | AzureStorageResource | AzureSearchResource | FoundryResource): Promise { + const rpcArgs: Record = { builder: this._handle, resource }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/withCapabilityHost', + rpcArgs + ); + return new AzureCognitiveServicesProjectResource(result, this._client); + } + + /** Associates a supported resource with a capability host on a Microsoft Foundry project. */ + withCapabilityHost(resource: AzureCosmosDBResource | AzureStorageResource | AzureSearchResource | FoundryResource): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._withCapabilityHostInternal(resource)); + } + /** @internal */ private async _addModelDeploymentFromModelInternal(name: string, model: FoundryModel): Promise { const rpcArgs: Record = { builder: this._handle, name, model }; @@ -7364,23 +10636,9 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureCognitiveServicesProjectResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -7389,28 +10647,15 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureCognitiveServicesProjectResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -7419,23 +10664,26 @@ export class AzureCognitiveServicesProjectResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureCognitiveServicesProjectResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureCognitiveServicesProjectResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureCognitiveServicesProjectResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -7555,8 +10803,8 @@ export class AzureCognitiveServicesProjectResourcePromise implements PromiseLike return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureCognitiveServicesProjectResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureCognitiveServicesProjectResourcePromise { return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -7565,6 +10813,11 @@ export class AzureCognitiveServicesProjectResourcePromise implements PromiseLike return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureCognitiveServicesProjectResourcePromise { return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -7610,6 +10863,11 @@ export class AzureCognitiveServicesProjectResourcePromise implements PromiseLike return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureCognitiveServicesProjectResourcePromise { return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -7650,6 +10908,31 @@ export class AzureCognitiveServicesProjectResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureCognitiveServicesProjectResourcePromise { return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -7695,6 +10978,16 @@ export class AzureCognitiveServicesProjectResourcePromise implements PromiseLike return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withAppInsights(appInsights))); } + /** Adds a capability host to a Microsoft Foundry project. */ + addCapabilityHost(name: string): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.addCapabilityHost(name))); + } + + /** Associates a supported resource with a capability host on a Microsoft Foundry project. */ + withCapabilityHost(resource: AzureCosmosDBResource | AzureStorageResource | AzureSearchResource | FoundryResource): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.withCapabilityHost(resource))); + } + /** Adds a model deployment to the parent Microsoft Foundry resource by using a model descriptor. */ addModelDeploymentFromModel(name: string, model: FoundryModel): FoundryDeploymentResourcePromise { return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.addModelDeploymentFromModel(name, model))); @@ -7775,29 +11068,19 @@ export class AzureCognitiveServicesProjectResourcePromise implements PromiseLike return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCognitiveServicesProjectResourcePromise { - return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureCognitiveServicesProjectResourcePromise { + return new AzureCognitiveServicesProjectResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -8037,11 +11320,26 @@ export class AzureContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureContainerRegistryResource(result, this._client); @@ -8056,7 +11354,7 @@ export class AzureContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureContainerRegistryResource(result, this._client); @@ -8176,6 +11474,86 @@ export class AzureContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -8389,23 +11767,9 @@ export class AzureContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureContainerRegistryResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -8414,28 +11778,15 @@ export class AzureContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureContainerRegistryResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -8444,23 +11795,26 @@ export class AzureContainerRegistryResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureContainerRegistryResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureContainerRegistryResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureContainerRegistryResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -8648,6 +12002,11 @@ export class AzureContainerRegistryResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureContainerRegistryResourcePromise { return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -8688,6 +12047,26 @@ export class AzureContainerRegistryResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureContainerRegistryResourcePromise { return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -8763,29 +12142,19 @@ export class AzureContainerRegistryResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureContainerRegistryResourcePromise { - return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureContainerRegistryResourcePromise { + return new AzureContainerRegistryResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -8871,7 +12240,7 @@ export class AzureCosmosDBContainerResource extends ResourceBuilderBase { + 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', @@ -8880,8 +12249,8 @@ export class AzureCosmosDBContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -9060,11 +12438,26 @@ export class AzureCosmosDBContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureCosmosDBContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureCosmosDBContainerResource(result, this._client); @@ -9079,7 +12472,7 @@ export class AzureCosmosDBContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureCosmosDBContainerResource(result, this._client); @@ -9199,6 +12592,106 @@ export class AzureCosmosDBContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureCosmosDBContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureCosmosDBContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureCosmosDBContainerResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureCosmosDBContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureCosmosDBContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -9331,8 +12824,8 @@ export class AzureCosmosDBContainerResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureCosmosDBContainerResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureCosmosDBContainerResourcePromise { return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -9341,6 +12834,11 @@ export class AzureCosmosDBContainerResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureCosmosDBContainerResourcePromise { return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -9386,6 +12884,11 @@ export class AzureCosmosDBContainerResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureCosmosDBContainerResourcePromise { return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9426,6 +12929,31 @@ export class AzureCosmosDBContainerResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBContainerResourcePromise { + return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureCosmosDBContainerResourcePromise { return new AzureCosmosDBContainerResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -9509,7 +13037,7 @@ export class AzureCosmosDBDatabaseResource extends ResourceBuilderBase { + 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', @@ -9518,8 +13046,8 @@ export class AzureCosmosDBDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -9698,11 +13235,26 @@ export class AzureCosmosDBDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureCosmosDBDatabaseResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureCosmosDBDatabaseResource(result, this._client); @@ -9717,7 +13269,7 @@ export class AzureCosmosDBDatabaseResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureCosmosDBDatabaseResource(result, this._client); @@ -9837,6 +13389,106 @@ export class AzureCosmosDBDatabaseResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureCosmosDBDatabaseResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureCosmosDBDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureCosmosDBDatabaseResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureCosmosDBDatabaseResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureCosmosDBDatabaseResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -10003,8 +13655,8 @@ export class AzureCosmosDBDatabaseResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureCosmosDBDatabaseResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureCosmosDBDatabaseResourcePromise { return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -10013,6 +13665,11 @@ export class AzureCosmosDBDatabaseResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureCosmosDBDatabaseResourcePromise { return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -10058,6 +13715,11 @@ export class AzureCosmosDBDatabaseResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureCosmosDBDatabaseResourcePromise { return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -10098,6 +13760,31 @@ export class AzureCosmosDBDatabaseResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBDatabaseResourcePromise { + return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureCosmosDBDatabaseResourcePromise { return new AzureCosmosDBDatabaseResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -10343,7 +14030,7 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -10352,8 +14039,8 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); @@ -10372,6 +14059,27 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { + 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 AzureCosmosDBEmulatorResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureCosmosDBEmulatorResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new AzureCosmosDBEmulatorResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -10503,41 +14211,11 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureCosmosDBEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new AzureCosmosDBEmulatorResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -10548,43 +14226,38 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase Promise): AzureCosmosDBEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -10673,52 +14346,39 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureCosmosDBEmulatorResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzureCosmosDBEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new AzureCosmosDBEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureCosmosDBEmulatorResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzureCosmosDBEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -11018,7 +14678,7 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); @@ -11048,7 +14708,7 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); @@ -11094,7 +14754,7 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); @@ -11199,7 +14859,7 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); @@ -11226,11 +14886,26 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureCosmosDBEmulatorResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); @@ -11245,7 +14920,7 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureCosmosDBEmulatorResource(result, this._client); @@ -11443,6 +15118,106 @@ export class AzureCosmosDBEmulatorResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureCosmosDBEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureCosmosDBEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureCosmosDBEmulatorResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureCosmosDBEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureCosmosDBEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -11736,8 +15511,8 @@ export class AzureCosmosDBEmulatorResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureCosmosDBEmulatorResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -11746,6 +15521,11 @@ export class AzureCosmosDBEmulatorResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -11786,31 +15566,21 @@ export class AzureCosmosDBEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureCosmosDBEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -11836,21 +15606,16 @@ export class AzureCosmosDBEmulatorResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureCosmosDBEmulatorResourcePromise { - return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -11996,6 +15761,11 @@ export class AzureCosmosDBEmulatorResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -12056,6 +15826,31 @@ export class AzureCosmosDBEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBEmulatorResourcePromise { + return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureCosmosDBEmulatorResourcePromise { return new AzureCosmosDBEmulatorResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -12193,7 +15988,7 @@ export class AzureCosmosDBResource extends ResourceBuilderBase { + 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', @@ -12202,8 +15997,8 @@ export class AzureCosmosDBResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -12543,11 +16347,26 @@ export class AzureCosmosDBResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureCosmosDBResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureCosmosDBResource(result, this._client); @@ -12562,7 +16381,7 @@ export class AzureCosmosDBResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureCosmosDBResource(result, this._client); @@ -12711,6 +16530,126 @@ export class AzureCosmosDBResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureCosmosDBResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureCosmosDBResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureCosmosDBResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureCosmosDBResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureCosmosDBResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureCosmosDBResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -12924,23 +16863,9 @@ export class AzureCosmosDBResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureCosmosDBResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -12949,28 +16874,15 @@ export class AzureCosmosDBResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureCosmosDBResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -12979,23 +16891,26 @@ export class AzureCosmosDBResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureCosmosDBResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureCosmosDBResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureCosmosDBResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -13226,8 +17141,8 @@ export class AzureCosmosDBResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureCosmosDBResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureCosmosDBResourcePromise { return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -13236,6 +17151,11 @@ export class AzureCosmosDBResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): AzureCosmosDBResourcePromise { return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -13321,6 +17241,11 @@ export class AzureCosmosDBResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureCosmosDBResourcePromise { return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -13366,6 +17291,36 @@ export class AzureCosmosDBResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureCosmosDBResourcePromise { return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -13441,29 +17396,19 @@ export class AzureCosmosDBResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureCosmosDBResourcePromise { - return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureCosmosDBResourcePromise { + return new AzureCosmosDBResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -13574,7 +17519,7 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + 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', @@ -13583,8 +17528,8 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyInternal(name, value)); } @@ -13603,6 +17548,15 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResourcePromise(this._withConnectionPropertyValueInternal(name, value)); } + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -13763,11 +17717,26 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< return new AzureDataLakeStorageFileSystemResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureDataLakeStorageFileSystemResource(result, this._client); @@ -13782,7 +17751,7 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureDataLakeStorageFileSystemResource(result, this._client); @@ -13902,6 +17871,106 @@ export class AzureDataLakeStorageFileSystemResource extends ResourceBuilderBase< ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureDataLakeStorageFileSystemResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -14034,8 +18103,8 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -14044,6 +18113,11 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -14089,6 +18163,11 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14129,6 +18208,31 @@ export class AzureDataLakeStorageFileSystemResourcePromise implements PromiseLik return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageFileSystemResourcePromise { + return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureDataLakeStorageFileSystemResourcePromise { return new AzureDataLakeStorageFileSystemResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -14212,7 +18316,7 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + 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', @@ -14221,8 +18325,8 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -14401,11 +18514,26 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureDataLakeStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); @@ -14420,7 +18548,7 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureDataLakeStorageResource(result, this._client); @@ -14540,6 +18668,106 @@ export class AzureDataLakeStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureDataLakeStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -14672,8 +18900,8 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureDataLakeStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -14682,6 +18910,11 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -14727,6 +18960,11 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14767,6 +19005,31 @@ export class AzureDataLakeStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureDataLakeStorageResourcePromise { + return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureDataLakeStorageResourcePromise { return new AzureDataLakeStorageResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -15009,11 +19272,26 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureEnvironmentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -15028,7 +19306,7 @@ export class AzureEnvironmentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureEnvironmentResource(result, this._client); @@ -15148,6 +19426,86 @@ export class AzureEnvironmentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureEnvironmentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -15355,6 +19713,11 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15395,6 +19758,26 @@ export class AzureEnvironmentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureEnvironmentResourcePromise { + return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureEnvironmentResourcePromise { return new AzureEnvironmentResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -15507,7 +19890,7 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { + 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', @@ -15516,8 +19899,8 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -15857,11 +20249,26 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKeyVaultResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureKeyVaultResource(result, this._client); @@ -15876,7 +20283,7 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureKeyVaultResource(result, this._client); @@ -16025,6 +20432,126 @@ export class AzureKeyVaultResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureKeyVaultResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -16238,23 +20765,9 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureKeyVaultResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -16263,28 +20776,15 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureKeyVaultResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -16293,23 +20793,26 @@ export class AzureKeyVaultResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureKeyVaultResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureKeyVaultResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureKeyVaultResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -16503,8 +21006,8 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureKeyVaultResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -16513,6 +21016,11 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -16598,6 +21106,11 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16643,6 +21156,36 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureKeyVaultResourcePromise { return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -16718,29 +21261,19 @@ export class AzureKeyVaultResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureKeyVaultResourcePromise { - return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureKeyVaultResourcePromise { + return new AzureKeyVaultResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -17005,11 +21538,26 @@ export class AzureKeyVaultSecretResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureKeyVaultSecretResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureKeyVaultSecretResource(result, this._client); @@ -17024,7 +21572,7 @@ export class AzureKeyVaultSecretResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureKeyVaultSecretResource(result, this._client); @@ -17144,6 +21692,86 @@ export class AzureKeyVaultSecretResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureKeyVaultSecretResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -17321,6 +21949,11 @@ export class AzureKeyVaultSecretResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureKeyVaultSecretResourcePromise { return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -17361,6 +21994,26 @@ export class AzureKeyVaultSecretResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureKeyVaultSecretResourcePromise { + return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureKeyVaultSecretResourcePromise { return new AzureKeyVaultSecretResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -17603,11 +22256,26 @@ export class AzureLogAnalyticsWorkspaceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureLogAnalyticsWorkspaceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureLogAnalyticsWorkspaceResource(result, this._client); @@ -17622,7 +22290,7 @@ export class AzureLogAnalyticsWorkspaceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureLogAnalyticsWorkspaceResource(result, this._client); @@ -17742,6 +22410,86 @@ export class AzureLogAnalyticsWorkspaceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureLogAnalyticsWorkspaceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureLogAnalyticsWorkspaceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureLogAnalyticsWorkspaceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureLogAnalyticsWorkspaceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -17955,23 +22703,9 @@ export class AzureLogAnalyticsWorkspaceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureLogAnalyticsWorkspaceResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -17980,28 +22714,15 @@ export class AzureLogAnalyticsWorkspaceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureLogAnalyticsWorkspaceResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -18010,23 +22731,26 @@ export class AzureLogAnalyticsWorkspaceResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureLogAnalyticsWorkspaceResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureLogAnalyticsWorkspaceResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureLogAnalyticsWorkspaceResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -18191,6 +22915,11 @@ export class AzureLogAnalyticsWorkspaceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureLogAnalyticsWorkspaceResourcePromise { return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18231,6 +22960,26 @@ export class AzureLogAnalyticsWorkspaceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureLogAnalyticsWorkspaceResourcePromise { return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -18306,29 +23055,19 @@ export class AzureLogAnalyticsWorkspaceResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureLogAnalyticsWorkspaceResourcePromise { - return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureLogAnalyticsWorkspaceResourcePromise { + return new AzureLogAnalyticsWorkspaceResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -18523,41 +23262,11 @@ export class AzurePromptAgentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzurePromptAgentResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new AzurePromptAgentResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -18568,43 +23277,38 @@ export class AzurePromptAgentResource extends ResourceBuilderBase Promise): AzurePromptAgentResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new AzurePromptAgentResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new AzurePromptAgentResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -18693,52 +23397,39 @@ export class AzurePromptAgentResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new AzurePromptAgentResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzurePromptAgentResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzurePromptAgentResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new AzurePromptAgentResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new AzurePromptAgentResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzurePromptAgentResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzurePromptAgentResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -19038,7 +23729,7 @@ export class AzurePromptAgentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzurePromptAgentResource(result, this._client); @@ -19068,7 +23759,7 @@ export class AzurePromptAgentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzurePromptAgentResource(result, this._client); @@ -19114,7 +23805,7 @@ export class AzurePromptAgentResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzurePromptAgentResource(result, this._client); @@ -19219,7 +23910,7 @@ export class AzurePromptAgentResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzurePromptAgentResource(result, this._client); @@ -19246,11 +23937,26 @@ export class AzurePromptAgentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzurePromptAgentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzurePromptAgentResource(result, this._client); @@ -19265,7 +23971,7 @@ export class AzurePromptAgentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzurePromptAgentResource(result, this._client); @@ -19444,6 +24150,106 @@ export class AzurePromptAgentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzurePromptAgentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzurePromptAgentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzurePromptAgentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzurePromptAgentResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzurePromptAgentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -19459,6 +24265,30 @@ export class AzurePromptAgentResource extends ResourceBuilderBase Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as HostedAgentConfigurationHandle; + const obj = new HostedAgentConfiguration(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (project !== undefined) rpcArgs.project = project; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/publishAsHostedAgentExecutable', + rpcArgs + ); + return new AzurePromptAgentResource(result, this._client); + } + + /** Publishes an executable resource as a hosted agent in Microsoft Foundry. */ + publishAsHostedAgent(options?: PublishAsHostedAgentOptions): AzurePromptAgentResourcePromise { + const project = options?.project; + const configure = options?.configure; + return new AzurePromptAgentResourcePromise(this._publishAsHostedAgentInternal(project, configure)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -19656,31 +24486,21 @@ export class AzurePromptAgentResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzurePromptAgentResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -19706,21 +24526,16 @@ export class AzurePromptAgentResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzurePromptAgentResourcePromise { - return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -19866,6 +24681,11 @@ export class AzurePromptAgentResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -19921,11 +24741,41 @@ export class AzurePromptAgentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); } + /** Publishes an executable resource as a hosted agent in Microsoft Foundry. */ + publishAsHostedAgent(options?: PublishAsHostedAgentOptions): AzurePromptAgentResourcePromise { + return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.publishAsHostedAgent(options))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): AzurePromptAgentResourcePromise { return new AzurePromptAgentResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -20178,11 +25028,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureProvisioningResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -20197,7 +25062,7 @@ export class AzureProvisioningResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureProvisioningResource(result, this._client); @@ -20317,6 +25182,86 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureProvisioningResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -20461,6 +25406,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as AzureResourceInfrastructureHandle; + const obj = new AzureResourceInfrastructure(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 AzureProvisioningResource(result, this._client); + } + + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._configureInfrastructureInternal(configure)); + } + /** @internal */ private async _publishAsConnectionStringInternal(): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -20510,23 +25475,9 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -20535,28 +25486,15 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureProvisioningResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -20565,23 +25503,26 @@ export class AzureProvisioningResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureProvisioningResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureProvisioningResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -20746,6 +25687,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -20786,6 +25732,26 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -20836,6 +25802,11 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.withParameterFromEndpoint(name, value))); } + /** Configures the Azure provisioning infrastructure callback */ + configureInfrastructure(configure: (obj: AzureResourceInfrastructure) => Promise): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.configureInfrastructure(configure))); + } + /** Publishes an Azure resource to the manifest as a connection string */ publishAsConnectionString(): AzureProvisioningResourcePromise { return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); @@ -20856,29 +25827,19 @@ export class AzureProvisioningResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureProvisioningResourcePromise { - return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureProvisioningResourcePromise { + return new AzureProvisioningResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -20959,7 +25920,7 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + 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', @@ -20968,8 +25929,8 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -21148,11 +26118,26 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureQueueStorageQueueResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); @@ -21167,7 +26152,7 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureQueueStorageQueueResource(result, this._client); @@ -21287,6 +26272,106 @@ export class AzureQueueStorageQueueResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureQueueStorageQueueResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -21419,8 +26504,8 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageQueueResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -21429,6 +26514,11 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -21474,6 +26564,11 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -21514,6 +26609,31 @@ export class AzureQueueStorageQueueResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageQueueResourcePromise { + return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureQueueStorageQueueResourcePromise { return new AzureQueueStorageQueueResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -21597,7 +26717,7 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { + 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', @@ -21606,8 +26726,8 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -21786,11 +26915,26 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureQueueStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureQueueStorageResource(result, this._client); @@ -21805,7 +26949,7 @@ export class AzureQueueStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureQueueStorageResource(result, this._client); @@ -21925,6 +27069,106 @@ export class AzureQueueStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureQueueStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -22057,8 +27301,8 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureQueueStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -22067,6 +27311,11 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -22112,6 +27361,11 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -22152,6 +27406,31 @@ export class AzureQueueStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureQueueStorageResourcePromise { + return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureQueueStorageResourcePromise { return new AzureQueueStorageResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -22235,7 +27514,7 @@ export class AzureSearchResource extends ResourceBuilderBase { + 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', @@ -22244,8 +27523,8 @@ export class AzureSearchResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -22424,11 +27712,26 @@ export class AzureSearchResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureSearchResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureSearchResource(result, this._client); @@ -22443,7 +27746,7 @@ export class AzureSearchResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureSearchResource(result, this._client); @@ -22563,6 +27866,106 @@ export class AzureSearchResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureSearchResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureSearchResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureSearchResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureSearchResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureSearchResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -22776,23 +28179,9 @@ export class AzureSearchResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureSearchResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -22801,28 +28190,15 @@ export class AzureSearchResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureSearchResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -22831,23 +28207,26 @@ export class AzureSearchResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureSearchResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureSearchResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureSearchResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -22967,8 +28346,8 @@ export class AzureSearchResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureSearchResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureSearchResourcePromise { return new AzureSearchResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -22977,6 +28356,11 @@ export class AzureSearchResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureSearchResourcePromise { return new AzureSearchResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -23022,6 +28406,11 @@ export class AzureSearchResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureSearchResourcePromise { return new AzureSearchResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -23062,6 +28451,31 @@ export class AzureSearchResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureSearchResourcePromise { return new AzureSearchResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -23137,29 +28551,19 @@ export class AzureSearchResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureSearchResourcePromise { - return new AzureSearchResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureSearchResourcePromise { + return new AzureSearchResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -23392,7 +28796,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -23401,8 +28805,8 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -23421,6 +28825,27 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + 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 AzureStorageEmulatorResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureStorageEmulatorResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new AzureStorageEmulatorResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -23552,41 +28977,11 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -23597,43 +28992,38 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase Promise): AzureStorageEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -23722,52 +29112,39 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new AzureStorageEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new AzureStorageEmulatorResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new AzureStorageEmulatorResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -24067,7 +29444,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -24097,7 +29474,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -24143,7 +29520,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -24248,7 +29625,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -24275,11 +29652,26 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureStorageEmulatorResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -24294,7 +29686,7 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureStorageEmulatorResource(result, this._client); @@ -24492,6 +29884,106 @@ export class AzureStorageEmulatorResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureStorageEmulatorResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -24819,8 +30311,8 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): AzureStorageEmulatorResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -24829,6 +30321,11 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -24869,31 +30366,21 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -24919,21 +30406,16 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): AzureStorageEmulatorResourcePromise { - return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -25079,6 +30561,11 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -25139,6 +30626,31 @@ export class AzureStorageEmulatorResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageEmulatorResourcePromise { + return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureStorageEmulatorResourcePromise { return new AzureStorageEmulatorResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -25606,11 +31118,26 @@ export class AzureStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureStorageResource(result, this._client); @@ -25625,7 +31152,7 @@ export class AzureStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureStorageResource(result, this._client); @@ -25774,6 +31301,106 @@ export class AzureStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -25987,23 +31614,9 @@ export class AzureStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureStorageResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -26012,28 +31625,15 @@ export class AzureStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureStorageResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -26042,23 +31642,26 @@ export class AzureStorageResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureStorageResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureStorageResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureStorageResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -26401,6 +32004,11 @@ export class AzureStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureStorageResourcePromise { return new AzureStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -26446,6 +32054,31 @@ export class AzureStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureStorageResourcePromise { return new AzureStorageResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -26521,29 +32154,19 @@ export class AzureStorageResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureStorageResourcePromise { - return new AzureStorageResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureStorageResourcePromise { + return new AzureStorageResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -26664,7 +32287,7 @@ export class AzureTableStorageResource extends ResourceBuilderBase { + 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', @@ -26673,8 +32296,8 @@ export class AzureTableStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -26853,11 +32485,26 @@ export class AzureTableStorageResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureTableStorageResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureTableStorageResource(result, this._client); @@ -26872,7 +32519,7 @@ export class AzureTableStorageResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureTableStorageResource(result, this._client); @@ -26992,6 +32639,106 @@ export class AzureTableStorageResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureTableStorageResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -27124,8 +32871,8 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): AzureTableStorageResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -27134,6 +32881,11 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -27179,6 +32931,11 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -27219,6 +32976,31 @@ export class AzureTableStorageResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureTableStorageResourcePromise { + return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureTableStorageResourcePromise { return new AzureTableStorageResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -27461,11 +33243,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new AzureUserAssignedIdentityResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -27480,7 +33277,7 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); @@ -27600,6 +33397,86 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 AzureUserAssignedIdentityResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -27813,23 +33690,9 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -27838,28 +33701,15 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureUserAssignedIdentityResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -27868,23 +33718,26 @@ export class AzureUserAssignedIdentityResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureUserAssignedIdentityResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureUserAssignedIdentityResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -28049,6 +33902,11 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -28089,6 +33947,26 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): AzureUserAssignedIdentityResourcePromise { return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -28164,29 +34042,19 @@ export class AzureUserAssignedIdentityResourcePromise implements PromiseLike obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureUserAssignedIdentityResourcePromise { - return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureUserAssignedIdentityResourcePromise { + return new AzureUserAssignedIdentityResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -28267,7 +34135,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -28276,8 +34144,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -28408,7 +34285,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -28438,7 +34315,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -28484,7 +34361,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -28533,11 +34410,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -28552,7 +34444,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -28672,6 +34564,106 @@ export class ConnectionStringResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ConnectionStringResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -28804,8 +34796,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -28814,6 +34806,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -28884,6 +34881,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -28924,6 +34926,31 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -29166,11 +35193,26 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -29185,7 +35227,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -29305,6 +35347,86 @@ export class ContainerRegistryResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerRegistryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -29482,6 +35604,11 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -29522,6 +35649,26 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -29568,6 +35715,260 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withBindMountInternal(source, target, isReadOnly)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEntrypointInternal(entrypoint)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageTagInternal(tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageRegistryInternal(registry)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + const tag = options?.tag; + return new ContainerResourcePromise(this._withImageInternal(image, tag)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImageSHA256Internal(sha256)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerRuntimeArgsInternal(args)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._withLifetimeInternal(lifetime)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._withImagePullPolicyInternal(pullPolicy)); + } + + /** @internal */ + private async _publishAsContainerInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsContainer', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsContainerInternal()); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + const dockerfilePath = options?.dockerfilePath; + const stage = options?.stage; + return new ContainerResourcePromise(this._withDockerfileInternal(contextPath, dockerfilePath, stage)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNameInternal(name)); + } + + /** @internal */ + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuildArg', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); + } + + /** @internal */ + private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withParameterBuildSecret', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._withBuildSecretInternal(name, value)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + + /** @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 ContainerResource(result, this._client); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEndpointProxySupportInternal(proxyEnabled)); + } + /** @internal */ private async _withDockerfileBaseImageInternal(buildImage?: string, runtimeImage?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -29587,6 +35988,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, alias }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withContainerNetworkAlias', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withContainerNetworkAliasInternal(alias)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -29637,58 +36053,43 @@ export class ContainerResource extends ResourceBuilderBase { - 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 ContainerResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { - const helpLink = options?.helpLink; - return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsConnectionStringInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/publishAsConnectionString', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._publishAsConnectionStringInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { + const helpLink = options?.helpLink; + return new ContainerResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -29699,43 +36100,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -29824,52 +36220,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -30169,7 +36552,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -30199,7 +36582,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -30245,7 +36628,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -30350,7 +36733,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -30377,11 +36760,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -30396,7 +36794,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -30566,6 +36964,25 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + const name = options?.name; + const isReadOnly = options?.isReadOnly; + return new ContainerResourcePromise(this._withVolumeInternal(target, name, isReadOnly)); + } + /** Gets the resource name */ async getResourceName(): Promise { const rpcArgs: Record = { resource: this._handle }; @@ -30575,6 +36992,106 @@ export class ContainerResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ContainerResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -30742,11 +37259,96 @@ export class ContainerResourcePromise implements PromiseLike return this._promise.then(onfulfilled, onrejected); } + /** Adds a bind mount */ + withBindMount(source: string, target: string, options?: WithBindMountOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBindMount(source, target, options))); + } + + /** Sets the container entrypoint */ + withEntrypoint(entrypoint: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEntrypoint(entrypoint))); + } + + /** Sets the container image tag */ + withImageTag(tag: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageTag(tag))); + } + + /** Sets the container image registry */ + withImageRegistry(registry: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageRegistry(registry))); + } + + /** Sets the container image */ + withImage(image: string, options?: WithImageOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImage(image, options))); + } + + /** Sets the image SHA256 digest */ + withImageSHA256(sha256: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImageSHA256(sha256))); + } + + /** Adds runtime arguments for the container */ + withContainerRuntimeArgs(args: string[]): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerRuntimeArgs(args))); + } + + /** Sets the lifetime behavior of the container resource */ + withLifetime(lifetime: ContainerLifetime): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withLifetime(lifetime))); + } + + /** Sets the container image pull policy */ + withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withImagePullPolicy(pullPolicy))); + } + + /** Configures the resource to be published as a container */ + publishAsContainer(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsContainer())); + } + + /** Configures the resource to use a Dockerfile */ + withDockerfile(contextPath: string, options?: WithDockerfileOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfile(contextPath, options))); + } + + /** Sets the container name */ + withContainerName(name: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); + } + + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); + } + + /** Adds a build secret from a parameter resource */ + withBuildSecret(name: string, value: ParameterResource): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + + /** Configures endpoint proxy support */ + withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); + } + /** Sets the base image for a Dockerfile build */ withDockerfileBaseImage(options?: WithDockerfileBaseImageOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withDockerfileBaseImage(options))); } + /** Adds a network alias for the container */ + withContainerNetworkAlias(alias: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerNetworkAlias(alias))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -30762,36 +37364,31 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } + /** Publishes the resource as a connection string */ + publishAsConnectionString(): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.publishAsConnectionString())); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -30817,21 +37414,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -30977,6 +37569,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -31027,11 +37624,41 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withPipelineConfiguration(callback))); } + /** Adds a volume */ + withVolume(target: string, options?: WithVolumeOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withVolume(target, options))); + } + /** Gets the resource name */ getResourceName(): Promise { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -31192,58 +37819,50 @@ export class CSharpAppResource extends ResourceBuilderBase { - 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 CSharpAppResource(result, this._client); - } - - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { - const helpLink = options?.helpLink; - return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); - } - - /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironment', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + const configure = options?.configure; + return new CSharpAppResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + 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/withEnvironmentExpression', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { + const helpLink = options?.helpLink; + return new CSharpAppResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -31254,43 +37873,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -31379,52 +37993,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -31709,7 +38310,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -31739,7 +38340,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -31769,7 +38370,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -31815,7 +38416,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -31920,7 +38521,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -31947,11 +38548,26 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -31966,7 +38582,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -32145,6 +38761,106 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 CSharpAppResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -32342,36 +39058,31 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); + } + /** Adds a required command dependency */ withRequiredCommand(command: string, options?: WithRequiredCommandOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -32397,21 +39108,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -32562,6 +39268,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -32617,6 +39328,31 @@ export class CSharpAppResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -32919,41 +39655,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -32964,43 +39670,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -33089,52 +39790,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -33434,7 +40122,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -33464,7 +40152,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -33510,7 +40198,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -33615,7 +40303,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -33642,11 +40330,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -33661,7 +40364,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -33840,6 +40543,106 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 DotnetToolResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -33855,6 +40658,30 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as HostedAgentConfigurationHandle; + const obj = new HostedAgentConfiguration(objHandle, this._client); + await configure(obj); + }) : undefined; + const rpcArgs: Record = { builder: this._handle }; + if (project !== undefined) rpcArgs.project = project; + if (configure !== undefined) rpcArgs.configure = configureId; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/publishAsHostedAgentExecutable', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Publishes an executable resource as a hosted agent in Microsoft Foundry. */ + publishAsHostedAgent(options?: PublishAsHostedAgentOptions): DotnetToolResourcePromise { + const project = options?.project; + const configure = options?.configure; + return new DotnetToolResourcePromise(this._publishAsHostedAgentInternal(project, configure)); + } + /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -34082,31 +40909,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -34132,21 +40949,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -34292,6 +41104,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -34347,11 +41164,41 @@ export class DotnetToolResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); } + /** Publishes an executable resource as a hosted agent in Microsoft Foundry. */ + publishAsHostedAgent(options?: PublishAsHostedAgentOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.publishAsHostedAgent(options))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -34427,6 +41274,71 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFile', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileInternal()); + } + + /** @internal */ + private async _publishAsDockerFileWithConfigureInternal(configure: (obj: ContainerResource) => Promise): Promise { + const configureId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(objHandle, this._client); + await configure(obj); + }); + const rpcArgs: Record = { builder: this._handle, configure: configureId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/publishAsDockerFileWithConfigure', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._publishAsDockerFileWithConfigureInternal(configure)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withExecutableCommandInternal(command)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withWorkingDirectoryInternal(workingDirectory)); + } + /** @internal */ private async _withMcpServerInternal(path?: string, endpointName?: string): Promise { const rpcArgs: Record = { builder: this._handle }; @@ -34494,41 +41406,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -34539,43 +41421,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -34664,52 +41541,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -35009,7 +41873,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -35039,7 +41903,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -35085,7 +41949,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -35190,7 +42054,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -35202,6 +42066,349 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withoutHttpsCertificate', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Removes HTTPS certificate configuration */ + withoutHttpsCertificate(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withoutHttpsCertificateInternal()); + } + + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + + /** @internal */ + private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, parent }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderParentRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets the parent relationship */ + withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); + } + + /** @internal */ + private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { + const rpcArgs: Record = { builder: this._handle, child }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderChildRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Sets a child relationship */ + withChildRelationship(child: ResourceBuilderBase): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withChildRelationshipInternal(child)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the icon for the resource */ + withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { + const iconVariant = options?.iconVariant; + return new ExecutableResourcePromise(this._withIconNameInternal(iconName, iconVariant)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Adds an HTTP health probe to the resource */ + 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 ExecutableResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); + } + + /** @internal */ + private async _excludeFromMcpInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/excludeFromMcp', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Excludes the resource from MCP server exposure */ + excludeFromMcp(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._excludeFromMcpInternal()); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the remote image name for publishing */ + withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); + } + + /** @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 ExecutableResource(result, this._client); + } + + /** Sets the remote image tag for publishing */ + withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); + } + + /** @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 PipelineStepContext(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 ExecutableResource(result, this._client); + } + + /** Adds a pipeline step to the resource */ + 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 ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); + } + + /** @internal */ + private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; + const arg = new PipelineConfigurationContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withPipelineConfigurationAsync', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via an async callback */ + withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); + } + + /** @internal */ + private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { + const callbackId = registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; + const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); + } + + /** Configures pipeline step dependencies via a callback */ + withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); + } + + /** Gets the resource name */ + 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 BeforeResourceStartedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExecutableResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._onResourceReadyInternal(callback)); + } + + /** @internal */ + private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { + const rpcArgs: Record = { builder: this._handle, target, roles }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/withFoundryRoleAssignments', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Assigns Microsoft Foundry roles to a resource */ + withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRoleAssignmentsInternal(target, roles)); + } + /** @internal */ private async _publishAsHostedAgentInternal(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): Promise { const configureId = configure ? registerCallback(async (objData: unknown) => { @@ -35226,234 +42433,6 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withoutHttpsCertificate', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Removes HTTPS certificate configuration */ - withoutHttpsCertificate(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withoutHttpsCertificateInternal()); - } - - /** @internal */ - private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, parent }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets the parent relationship */ - withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withParentRelationshipInternal(parent)); - } - - /** @internal */ - private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { - const rpcArgs: Record = { builder: this._handle, child }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets a child relationship */ - withChildRelationship(child: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withChildRelationshipInternal(child)); - } - - /** @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 ExecutableResource(result, this._client); - } - - /** Sets the icon for the resource */ - withIconName(iconName: string, options?: WithIconNameOptions): ExecutableResourcePromise { - const iconVariant = options?.iconVariant; - return new ExecutableResourcePromise(this._withIconNameInternal(iconName, iconVariant)); - } - - /** @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 ExecutableResource(result, this._client); - } - - /** Adds an HTTP health probe to the resource */ - 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 ExecutableResourcePromise(this._withHttpProbeInternal(probeType, path, initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold, endpointName)); - } - - /** @internal */ - private async _excludeFromMcpInternal(): Promise { - const rpcArgs: Record = { builder: this._handle }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/excludeFromMcp', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Excludes the resource from MCP server exposure */ - excludeFromMcp(): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._excludeFromMcpInternal()); - } - - /** @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 ExecutableResource(result, this._client); - } - - /** Sets the remote image name for publishing */ - withRemoteImageName(remoteImageName: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withRemoteImageNameInternal(remoteImageName)); - } - - /** @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 ExecutableResource(result, this._client); - } - - /** Sets the remote image tag for publishing */ - withRemoteImageTag(remoteImageTag: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withRemoteImageTagInternal(remoteImageTag)); - } - - /** @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 PipelineStepContext(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 ExecutableResource(result, this._client); - } - - /** Adds a pipeline step to the resource */ - 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 ExecutableResourcePromise(this._withPipelineStepFactoryInternal(stepName, callback, dependsOn, requiredBy, tags, description)); - } - - /** @internal */ - private async _withPipelineConfigurationAsyncInternal(callback: (arg: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as PipelineConfigurationContextHandle; - const arg = new PipelineConfigurationContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withPipelineConfigurationAsync', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Configures pipeline step dependencies via an async callback */ - withPipelineConfigurationAsync(callback: (arg: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationAsyncInternal(callback)); - } - - /** @internal */ - private async _withPipelineConfigurationInternal(callback: (obj: PipelineConfigurationContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as PipelineConfigurationContextHandle; - const obj = new PipelineConfigurationContext(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 ExecutableResource(result, this._client); - } - - /** Configures pipeline step dependencies via a callback */ - withPipelineConfiguration(callback: (obj: PipelineConfigurationContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withPipelineConfigurationInternal(callback)); - } - - /** Gets the resource name */ - async getResourceName(): Promise { - const rpcArgs: Record = { resource: this._handle }; - return await this._client.invokeCapability( - 'Aspire.Hosting/getResourceName', - rpcArgs - ); - } - - /** @internal */ - private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { - const rpcArgs: Record = { builder: this._handle, target, roles }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Foundry/withFoundryRoleAssignments', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Assigns Microsoft Foundry roles to a resource */ - withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withRoleAssignmentsInternal(target, roles)); - } - /** @internal */ private async _withEnvironmentFromOutputInternal(name: string, bicepOutputReference: BicepOutputReference): Promise { const rpcArgs: Record = { builder: this._handle, name, bicepOutputReference }; @@ -35611,6 +42590,26 @@ export class ExecutableResourcePromise implements PromiseLike obj.withDockerfileBaseImage(options))); } + /** Publishes the executable as a Docker container */ + publishAsDockerFile(): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFile())); + } + + /** Publishes an executable as a Docker file with optional container configuration */ + publishAsDockerFileWithConfigure(configure: (obj: ContainerResource) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsDockerFileWithConfigure(configure))); + } + + /** Sets the executable command */ + withExecutableCommand(command: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withExecutableCommand(command))); + } + + /** Sets the executable working directory */ + withWorkingDirectory(workingDirectory: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withWorkingDirectory(workingDirectory))); + } + /** Configures an MCP server endpoint on the resource */ withMcpServer(options?: WithMcpServerOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withMcpServer(options))); @@ -35631,31 +42630,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -35681,21 +42670,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -35836,16 +42820,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withHttpsDeveloperCertificate(options))); } - /** Publishes an executable resource as a hosted agent in Microsoft Foundry. */ - publishAsHostedAgent(options?: PublishAsHostedAgentOptions): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsHostedAgent(options))); - } - /** Removes HTTPS certificate configuration */ withoutHttpsCertificate(): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -35901,11 +42885,41 @@ export class ExecutableResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); } + /** Publishes an executable resource as a hosted agent in Microsoft Foundry. */ + publishAsHostedAgent(options?: PublishAsHostedAgentOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.publishAsHostedAgent(options))); + } + /** Sets an environment variable from a Bicep output reference */ withEnvironmentFromOutput(name: string, bicepOutputReference: BicepOutputReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentFromOutput(name, bicepOutputReference))); @@ -36177,11 +43191,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -36196,7 +43225,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -36316,6 +43345,86 @@ export class ExternalServiceResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ExternalServiceResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -36498,6 +43607,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -36538,6 +43652,26 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -36680,6 +43814,17 @@ export class FoundryDeploymentResource extends ResourceBuilderBase => { + const handle = await this._client.invokeCapability( + 'Aspire.Hosting.Foundry/FoundryDeploymentResource.parent', + { context: this._handle } + ); + return new FoundryResource(handle, this._client); + }, + }; + /** Gets the ConnectionStringExpression property */ connectionStringExpression = { get: async (): Promise => { @@ -36737,7 +43882,7 @@ export class FoundryDeploymentResource extends ResourceBuilderBase { + 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', @@ -36746,8 +43891,8 @@ export class FoundryDeploymentResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -36926,11 +44080,26 @@ export class FoundryDeploymentResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new FoundryDeploymentResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new FoundryDeploymentResource(result, this._client); @@ -36945,7 +44114,7 @@ export class FoundryDeploymentResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new FoundryDeploymentResource(result, this._client); @@ -37065,6 +44234,106 @@ export class FoundryDeploymentResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 FoundryDeploymentResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 FoundryDeploymentResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 FoundryDeploymentResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 FoundryDeploymentResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 FoundryDeploymentResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withPropertiesInternal(configure: (obj: FoundryDeploymentResource) => Promise): Promise { const configureId = registerCallback(async (objData: unknown) => { @@ -37217,8 +44486,8 @@ export class FoundryDeploymentResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): FoundryDeploymentResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): FoundryDeploymentResourcePromise { return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -37227,6 +44496,11 @@ export class FoundryDeploymentResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): FoundryDeploymentResourcePromise { return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -37272,6 +44546,11 @@ export class FoundryDeploymentResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): FoundryDeploymentResourcePromise { return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -37312,6 +44591,31 @@ export class FoundryDeploymentResourcePromise implements PromiseLike obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): FoundryDeploymentResourcePromise { + return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Configures properties of a Microsoft Foundry deployment resource. */ withProperties(configure: (obj: FoundryDeploymentResource) => Promise): FoundryDeploymentResourcePromise { return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.withProperties(configure))); @@ -37419,7 +44723,7 @@ export class FoundryResource extends ResourceBuilderBase } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + 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', @@ -37428,8 +44732,8 @@ export class FoundryResource extends ResourceBuilderBase return new FoundryResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): FoundryResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): FoundryResourcePromise { return new FoundryResourcePromise(this._withConnectionPropertyInternal(name, value)); } @@ -37448,6 +44752,15 @@ export class FoundryResource extends ResourceBuilderBase return new FoundryResourcePromise(this._withConnectionPropertyValueInternal(name, value)); } + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @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 }; @@ -37769,11 +45082,26 @@ export class FoundryResource extends ResourceBuilderBase return new FoundryResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new FoundryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): FoundryResourcePromise { + return new FoundryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new FoundryResource(result, this._client); @@ -37788,7 +45116,7 @@ export class FoundryResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new FoundryResource(result, this._client); @@ -37937,6 +45265,126 @@ export class FoundryResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 FoundryResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 FoundryResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onConnectionStringAvailableInternal(callback: (arg: ConnectionStringAvailableEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ConnectionStringAvailableEventHandle; + const arg = new ConnectionStringAvailableEvent(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 FoundryResource(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._onConnectionStringAvailableInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 FoundryResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 FoundryResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 FoundryResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _addDeploymentInternal(name: string, modelName: string, modelVersion: string, format: string): Promise { const rpcArgs: Record = { builder: this._handle, name, modelName, modelVersion, format }; @@ -38210,23 +45658,9 @@ export class FoundryResource extends ResourceBuilderBase } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new FoundryResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): FoundryResourcePromise { - return new FoundryResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -38235,28 +45669,15 @@ export class FoundryResource extends ResourceBuilderBase } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): FoundryResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): FoundryResourcePromise { + const resourceGroup = options?.resourceGroup; return new FoundryResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new FoundryResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): FoundryResourcePromise { - return new FoundryResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -38265,23 +45686,26 @@ export class FoundryResource extends ResourceBuilderBase } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): FoundryResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): FoundryResourcePromise { + const resourceGroup = options?.resourceGroup; return new FoundryResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new FoundryResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): FoundryResourcePromise { - return new FoundryResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): FoundryResourcePromise { + const resourceGroup = options?.resourceGroup; + return new FoundryResourcePromise(this._asExistingInternal(name, resourceGroup)); } /** @internal */ @@ -38406,8 +45830,8 @@ export class FoundryResourcePromise implements PromiseLike { return new FoundryResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): FoundryResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): FoundryResourcePromise { return new FoundryResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -38416,6 +45840,11 @@ export class FoundryResourcePromise implements PromiseLike { return new FoundryResourcePromise(this._promise.then(obj => obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Adds a network endpoint */ withEndpoint(options?: WithEndpointOptions): FoundryResourcePromise { return new FoundryResourcePromise(this._promise.then(obj => obj.withEndpoint(options))); @@ -38501,6 +45930,11 @@ export class FoundryResourcePromise implements PromiseLike { return new FoundryResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): FoundryResourcePromise { return new FoundryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -38546,6 +45980,36 @@ export class FoundryResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Adds a Microsoft Foundry deployment resource to a Microsoft Foundry resource. */ addDeployment(name: string, modelName: string, modelVersion: string, format: string): FoundryDeploymentResourcePromise { return new FoundryDeploymentResourcePromise(this._promise.then(obj => obj.addDeployment(name, modelName, modelVersion, format))); @@ -38641,29 +46105,19 @@ export class FoundryResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): FoundryResourcePromise { - return new FoundryResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): FoundryResourcePromise { - return new FoundryResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): FoundryResourcePromise { - return new FoundryResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): FoundryResourcePromise { - return new FoundryResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): FoundryResourcePromise { - return new FoundryResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): FoundryResourcePromise { + return new FoundryResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } /** Configures a compute environment resource to use an Azure Container Registry. */ @@ -38920,11 +46374,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -38939,7 +46408,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -39059,6 +46528,86 @@ export class ParameterResource extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ParameterResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -39241,6 +46790,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -39281,6 +46835,26 @@ export class ParameterResourcePromise implements PromiseLike return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -39396,74 +46970,76 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withRequiredCommandInternal(command: string, helpLink?: string): Promise { - const rpcArgs: Record = { builder: this._handle, command }; - if (helpLink !== undefined) rpcArgs.helpLink = helpLink; + private async _withReplicasInternal(replicas: number): Promise { + const rpcArgs: Record = { builder: this._handle, replicas }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withRequiredCommand', + 'Aspire.Hosting/withReplicas', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - const helpLink = options?.helpLink; - return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReplicasInternal(replicas)); } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _disableForwardedHeadersInternal(): Promise { + const rpcArgs: Record = { builder: this._handle }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', + 'Aspire.Hosting/disableForwardedHeaders', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._disableForwardedHeadersInternal()); } /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; + private async _publishAsDockerFileInternal(configure?: (obj: ContainerResource) => Promise): Promise { + const configureId = configure ? registerCallback(async (objData: unknown) => { + const objHandle = wrapIfHandle(objData) as ContainerResourceHandle; + const obj = new ContainerResource(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/withEnvironmentExpression', + 'Aspire.Hosting/publishProjectAsDockerFileWithConfigure', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + const configure = options?.configure; + return new ProjectResourcePromise(this._publishAsDockerFileInternal(configure)); } /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + 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/withEnvironmentCallback', + 'Aspire.Hosting/withRequiredCommand', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + const helpLink = options?.helpLink; + return new ProjectResourcePromise(this._withRequiredCommandInternal(command, helpLink)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (argData: unknown) => { const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; const arg = new EnvironmentCallbackContext(argHandle, this._client); @@ -39471,15 +47047,15 @@ export class ProjectResource extends ResourceBuilderBase }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentCallback', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ @@ -39497,6 +47073,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } + /** @internal */ + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withEnvironment', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); + } + /** @internal */ private async _withEnvironmentParameterInternal(name: string, parameter: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, parameter }; @@ -39583,52 +47174,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -39913,7 +47491,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -39943,7 +47521,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -39973,7 +47551,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -40019,7 +47597,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -40124,7 +47702,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -40151,11 +47729,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -40170,7 +47763,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -40349,6 +47942,106 @@ export class ProjectResource extends ResourceBuilderBase ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceEndpointsAllocatedInternal(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 ProjectResource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -40536,29 +48229,29 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withOtlpExporterProtocol(protocol))); } - /** Adds a required command dependency */ - withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); + /** Sets the number of replicas */ + withReplicas(replicas: number): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReplicas(replicas))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + /** Disables forwarded headers for the project */ + disableForwardedHeaders(): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.disableForwardedHeaders())); } - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); + /** Publishes a project as a Docker file with optional container configuration */ + publishAsDockerFile(options?: PublishAsDockerFileOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.publishAsDockerFile(options))); } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); + /** Adds a required command dependency */ + withRequiredCommand(command: string, options?: WithRequiredCommandOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); + /** Sets environment variables via callback */ + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } /** Sets an environment variable from an endpoint reference */ @@ -40566,6 +48259,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -40591,21 +48289,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -40756,6 +48449,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -40811,6 +48509,31 @@ export class ProjectResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -40921,23 +48644,9 @@ export class AzureResource extends ResourceBuilderBase { } /** @internal */ - private async _runAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/runAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._runAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _runAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _runAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/runAsExisting', rpcArgs @@ -40946,28 +48655,15 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._runAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _publishAsExistingFromParametersInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/publishAsExistingFromParameters', - rpcArgs - ); - return new AzureResource(result, this._client); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._publishAsExistingFromParametersInternal(nameParameter, resourceGroupParameter)); - } - - /** @internal */ - private async _publishAsExistingInternal(name: string, resourceGroup: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, resourceGroup }; + private async _publishAsExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( 'Aspire.Hosting.Azure/publishAsExisting', rpcArgs @@ -40976,23 +48672,26 @@ export class AzureResource extends ResourceBuilderBase { } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; return new AzureResourcePromise(this._publishAsExistingInternal(name, resourceGroup)); } /** @internal */ - private async _asExistingInternal(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): Promise { - const rpcArgs: Record = { builder: this._handle, nameParameter, resourceGroupParameter }; + private async _asExistingInternal(name: string | ParameterResource, resourceGroup?: string | ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name }; + if (resourceGroup !== undefined) rpcArgs.resourceGroup = resourceGroup; const result = await this._client.invokeCapability( - 'Aspire.Hosting.Azure/asExistingFromParameters', + 'Aspire.Hosting.Azure/asExisting', rpcArgs ); return new AzureResource(result, this._client); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._asExistingInternal(nameParameter, resourceGroupParameter)); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + const resourceGroup = options?.resourceGroup; + return new AzureResourcePromise(this._asExistingInternal(name, resourceGroup)); } } @@ -41032,29 +48731,19 @@ export class AzureResourcePromise implements PromiseLike { return this._promise.then(obj => obj.isExisting()); } - /** Marks an Azure resource as existing in run mode by using parameter resources */ - runAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExistingFromParameters(nameParameter, resourceGroupParameter))); - } - /** Marks an Azure resource as existing in run mode */ - runAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, resourceGroup))); - } - - /** Marks an Azure resource as existing in publish mode by using parameter resources */ - publishAsExistingFromParameters(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExistingFromParameters(nameParameter, resourceGroupParameter))); + runAsExisting(name: string | ParameterResource, options?: RunAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.runAsExisting(name, options))); } /** Marks an Azure resource as existing in publish mode */ - publishAsExisting(name: string, resourceGroup: string): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, resourceGroup))); + publishAsExisting(name: string | ParameterResource, options?: PublishAsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.publishAsExisting(name, options))); } - /** Marks an Azure resource as existing in both run and publish modes by using parameter resources */ - asExisting(nameParameter: ParameterResource, resourceGroupParameter: ParameterResource): AzureResourcePromise { - return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(nameParameter, resourceGroupParameter))); + /** Marks an Azure resource as existing in both run and publish modes */ + asExisting(name: string | ParameterResource, options?: AsExistingOptions): AzureResourcePromise { + return new AzureResourcePromise(this._promise.then(obj => obj.asExisting(name, options))); } } @@ -41160,7 +48849,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -41400,11 +49089,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -41419,7 +49123,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -41539,6 +49243,86 @@ export class Resource extends ResourceBuilderBase { ); } + /** @internal */ + private async _onBeforeResourceStartedInternal(callback: (arg: BeforeResourceStartedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as BeforeResourceStartedEventHandle; + const arg = new BeforeResourceStartedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onBeforeResourceStartedInternal(callback)); + } + + /** @internal */ + private async _onResourceStoppedInternal(callback: (arg: ResourceStoppedEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceStoppedEventHandle; + const arg = new ResourceStoppedEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceStoppedInternal(callback)); + } + + /** @internal */ + private async _onInitializeResourceInternal(callback: (arg: InitializeResourceEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as InitializeResourceEventHandle; + const arg = new InitializeResourceEvent(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 Resource(result, this._client); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onInitializeResourceInternal(callback)); + } + + /** @internal */ + private async _onResourceReadyInternal(callback: (arg: ResourceReadyEvent) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceReadyEventHandle; + const arg = new ResourceReadyEvent(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 Resource(result, this._client); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._onResourceReadyInternal(callback)); + } + /** @internal */ private async _withRoleAssignmentsInternal(target: FoundryResource, roles: FoundryRole[]): Promise { const rpcArgs: Record = { builder: this._handle, target, roles }; @@ -41716,6 +49500,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -41756,6 +49545,26 @@ export class ResourcePromise implements PromiseLike { return this._promise.then(obj => obj.getResourceName()); } + /** Subscribes to the BeforeResourceStarted event */ + onBeforeResourceStarted(callback: (arg: BeforeResourceStartedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onBeforeResourceStarted(callback))); + } + + /** Subscribes to the ResourceStopped event */ + onResourceStopped(callback: (arg: ResourceStoppedEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceStopped(callback))); + } + + /** Subscribes to the InitializeResource event */ + onInitializeResource(callback: (arg: InitializeResourceEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onInitializeResource(callback))); + } + + /** Subscribes to the ResourceReady event */ + onResourceReady(callback: (arg: ResourceReadyEvent) => Promise): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.onResourceReady(callback))); + } + /** Assigns Microsoft Foundry roles to a resource */ withRoleAssignments(target: FoundryResource, roles: FoundryRole[]): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withRoleAssignments(target, roles))); @@ -41901,7 +49710,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -41910,8 +49719,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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 ConnectionStringAvailableEvent(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 ResourceWithConnectionString(result, this._client); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._onConnectionStringAvailableInternal(callback)); + } + } /** @@ -41947,8 +49785,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -41957,6 +49795,16 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + + /** Subscribes to the ConnectionStringAvailable event */ + onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { + return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); + } + } // ============================================================================ @@ -42245,6 +50093,26 @@ export class ResourceWithEndpoints extends ResourceBuilderBase Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as ResourceEndpointsAllocatedEventHandle; + const arg = new ResourceEndpointsAllocatedEvent(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 ResourceWithEndpoints(result, this._client); + } + + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._onResourceEndpointsAllocatedInternal(callback)); + } + } /** @@ -42312,6 +50180,11 @@ export class ResourceWithEndpointsPromise implements PromiseLike obj.withHttpProbe(probeType, options))); } + /** Subscribes to the ResourceEndpointsAllocated event */ + onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise): ResourceWithEndpointsPromise { + return new ResourceWithEndpointsPromise(this._promise.then(obj => obj.onResourceEndpointsAllocated(callback))); + } + } // ============================================================================ @@ -42354,41 +50227,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -42399,43 +50242,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -42469,52 +50307,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -42597,7 +50422,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -42681,31 +50506,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -42716,21 +50531,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -42778,34 +50588,6 @@ export class ResourceWithEnvironmentPromise implements PromiseLike { - constructor(handle: IResourceWithServiceDiscoveryHandle, client: AspireClientRpc) { - super(handle, client); - } - -} - -/** - * Thenable wrapper for ResourceWithServiceDiscovery that enables fluent chaining. - * @example - * await builder.addSomething().withX().withY(); - */ -export class ResourceWithServiceDiscoveryPromise implements PromiseLike { - constructor(private _promise: Promise) {} - - then( - onfulfilled?: ((value: ResourceWithServiceDiscovery) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): PromiseLike { - return this._promise.then(onfulfilled, onrejected); - } - -} - // ============================================================================ // ResourceWithWaitSupport // ============================================================================ @@ -42819,7 +50601,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -42849,7 +50631,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -42880,7 +50662,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -42999,7 +50781,7 @@ export async function createBuilder(options?: CreateBuilderOptions): Promise { // ============================================================================ // Register wrapper factories for typed handle wrapping in callbacks +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent', (handle, client) => new AfterResourcesCreatedEvent(handle as AfterResourcesCreatedEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureResourceInfrastructure', (handle, client) => new AzureResourceInfrastructure(handle as AzureResourceInfrastructureHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent', (handle, client) => new BeforeResourceStartedEvent(handle as BeforeResourceStartedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.BeforeStartEvent', (handle, client) => new BeforeStartEvent(handle as BeforeStartEventHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.BicepOutputReference', (handle, client) => new BicepOutputReference(handle as BicepOutputReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackContext', (handle, client) => new CommandLineArgsCallbackContext(handle as CommandLineArgsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent', (handle, client) => new ConnectionStringAvailableEvent(handle as ConnectionStringAvailableEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplication', (handle, client) => new DistributedApplication(handle as DistributedApplicationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.DistributedApplicationExecutionContext', (handle, client) => new DistributedApplicationExecutionContext(handle as DistributedApplicationExecutionContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.DistributedApplicationModel', (handle, client) => new DistributedApplicationModel(handle as DistributedApplicationModelHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReference', (handle, client) => new EndpointReference(handle as EndpointReferenceHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression', (handle, client) => new EndpointReferenceExpression(handle as EndpointReferenceExpressionHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.EnvironmentCallbackContext', (handle, client) => new EnvironmentCallbackContext(handle as EnvironmentCallbackContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ExecuteCommandContext', (handle, client) => new ExecuteCommandContext(handle as ExecuteCommandContextHandle, client)); +registerHandleWrapper('Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration', (handle, client) => new HostedAgentConfiguration(handle as HostedAgentConfigurationHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.InitializeResourceEvent', (handle, client) => new InitializeResourceEvent(handle as InitializeResourceEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineConfigurationContext', (handle, client) => new PipelineConfigurationContext(handle as PipelineConfigurationContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineContext', (handle, client) => new PipelineContext(handle as PipelineContextHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStep', (handle, client) => new PipelineStep(handle as PipelineStepHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepContext', (handle, client) => new PipelineStepContext(handle as PipelineStepContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineStepFactoryContext', (handle, client) => new PipelineStepFactoryContext(handle as PipelineStepFactoryContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.PipelineSummary', (handle, client) => new PipelineSummary(handle as PipelineSummaryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ProjectResourceOptions', (handle, client) => new ProjectResourceOptions(handle as ProjectResourceOptionsHandle, client)); -registerHandleWrapper('Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.HostedAgentConfiguration', (handle, client) => new HostedAgentConfiguration(handle as HostedAgentConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ReferenceExpressionBuilder', (handle, client) => new ReferenceExpressionBuilder(handle as ReferenceExpressionBuilderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceEndpointsAllocatedEvent', (handle, client) => new ResourceEndpointsAllocatedEvent(handle as ResourceEndpointsAllocatedEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceLoggerService', (handle, client) => new ResourceLoggerService(handle as ResourceLoggerServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceNotificationService', (handle, client) => new ResourceNotificationService(handle as ResourceNotificationServiceHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceReadyEvent', (handle, client) => new ResourceReadyEvent(handle as ResourceReadyEventHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceStoppedEvent', (handle, client) => new ResourceStoppedEvent(handle as ResourceStoppedEventHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.ResourceUrlsCallbackContext', (handle, client) => new ResourceUrlsCallbackContext(handle as ResourceUrlsCallbackContextHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.UpdateCommandStateContext', (handle, client) => new UpdateCommandStateContext(handle as UpdateCommandStateContextHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Configuration.Abstractions/Microsoft.Extensions.Configuration.IConfiguration', (handle, client) => new Configuration(handle as IConfigurationHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IDistributedApplicationBuilder', (handle, client) => new DistributedApplicationBuilder(handle as IDistributedApplicationBuilderHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Eventing.IDistributedApplicationEventing', (handle, client) => new DistributedApplicationEventing(handle as IDistributedApplicationEventingHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Hosting.Abstractions/Microsoft.Extensions.Hosting.IHostEnvironment', (handle, client) => new HostEnvironment(handle as IHostEnvironmentHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILogger', (handle, client) => new Logger(handle as ILoggerHandle, client)); +registerHandleWrapper('Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.ILoggerFactory', (handle, client) => new LoggerFactory(handle as ILoggerFactoryHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingStep', (handle, client) => new ReportingStep(handle as IReportingStepHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.Pipelines.IReportingTask', (handle, client) => new ReportingTask(handle as IReportingTaskHandle, client)); +registerHandleWrapper('System.ComponentModel/System.IServiceProvider', (handle, client) => new ServiceProvider(handle as IServiceProviderHandle, client)); +registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IUserSecretsManager', (handle, client) => new UserSecretsManager(handle as IUserSecretsManagerHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.ApplicationInsights/Aspire.Hosting.Azure.AzureApplicationInsightsResource', (handle, client) => new AzureApplicationInsightsResource(handle as AzureApplicationInsightsResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure/Aspire.Hosting.Azure.AzureBicepResource', (handle, client) => new AzureBicepResource(handle as AzureBicepResourceHandle, client)); registerHandleWrapper('Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.AzureBlobStorageContainerResource', (handle, client) => new AzureBlobStorageContainerResource(handle as AzureBlobStorageContainerResourceHandle, client)); @@ -43112,5 +50917,5 @@ registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceW registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithContainerFiles', (handle, client) => new ResourceWithContainerFiles(handle as IResourceWithContainerFilesHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEndpoints', (handle, client) => new ResourceWithEndpoints(handle as IResourceWithEndpointsHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment', (handle, client) => new ResourceWithEnvironment(handle as IResourceWithEnvironmentHandle, client)); -registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.IResourceWithServiceDiscovery', (handle, client) => new ResourceWithServiceDiscovery(handle as IResourceWithServiceDiscoveryHandle, client)); registerHandleWrapper('Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport', (handle, client) => new ResourceWithWaitSupport(handle as IResourceWithWaitSupportHandle, client)); + diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/base.ts index 9a3427e7e72..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/base.ts @@ -1,8 +1,8 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression -import { Handle, AspireClient, MarshalledHandle } from './transport.js'; +// base.ts - Core Aspire types: base classes, ReferenceExpression +import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience -export { Handle, AspireClient, CapabilityError, registerCallback, unregisterCallback, registerCancellation, unregisterCancellation } from './transport.js'; +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'; @@ -138,7 +138,7 @@ export class ReferenceExpression { if (this.isConditional) { return { $expr: { - condition: this._condition instanceof Handle ? this._condition.toJSON() : this._condition, + condition: extractHandleForExpr(this._condition), whenTrue: this._whenTrue!.toJSON(), whenFalse: this._whenFalse!.toJSON(), matchValue: this._matchValue! @@ -154,6 +154,30 @@ export class ReferenceExpression { }; } + /** + * 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 { + if (!this._handle || !this._client) { + throw new Error('getValue is only available on server-returned ReferenceExpression instances'); + } + const cancellationTokenId = registerCancellation(this._client, cancellationToken); + try { + const rpcArgs: Record = { context: this._handle }; + if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; + return await this._client.invokeCapability( + 'Aspire.Hosting.ApplicationModel/getValue', + rpcArgs + ); + } finally { + unregisterCancellation(cancellationTokenId); + } + } + /** * String representation for debugging. */ @@ -168,6 +192,10 @@ export class ReferenceExpression { } } +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. @@ -193,15 +221,15 @@ function extractHandleForExpr(value: unknown): unknown { return value.toJSON(); } - // Objects with $handle property (already in handle format) - if (typeof value === 'object' && value !== null && '$handle' in value) { + // 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 handle + // 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) { + if (json && typeof json === 'object' && ('$handle' in json || '$expr' in json)) { return json; } } @@ -364,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -523,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/transport.ts index 7ee1ba87e3f..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -93,6 +94,47 @@ export function isMarshalledHandle(value: unknown): value is MarshalledHandle { ); } +function isAbortSignal(value: unknown): value is AbortSignal { + return ( + value !== null && + typeof value === 'object' && + 'aborted' in value && + 'addEventListener' in value && + 'removeEventListener' in value + ); +} + +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 // ============================================================================ @@ -136,6 +178,92 @@ export class 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); + * ``` + */ +export class CancellationToken { + private readonly _signal?: AbortSignal; + private readonly _remoteTokenId?: string; + + constructor(signal?: AbortSignal); + constructor(tokenId?: string); + constructor(value?: AbortSignal | string | null) { + if (typeof value === 'string') { + this._remoteTokenId = value; + } else if (isAbortSignal(value)) { + this._signal = value; + } + } + + /** + * Creates a cancellation token from a local {@link AbortSignal}. + */ + 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 (value instanceof CancellationToken) { + return value; + } + + if (typeof value === 'string') { + return new CancellationToken(value); + } + + if (isAbortSignal(value)) { + return new CancellationToken(value); + } + + return new CancellationToken(); + } + + /** + * Serializes the token for JSON-RPC transport. + */ + toJSON(): string | undefined { + return this._remoteTokenId; + } + + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; + } + + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); + } +} + // ============================================================================ // Handle Wrapper Registry // ============================================================================ @@ -167,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -240,9 +381,7 @@ function validateCapabilityArgs( return; } - const seen = new Set(); - - const validateValue = (value: unknown, path: string): void => { + const validateValue = (value: unknown, path: string, ancestors: Set): void => { if (value === null || value === undefined) { return; } @@ -259,26 +398,29 @@ function validateCapabilityArgs( return; } - if (seen.has(value)) { - return; + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); } - seen.add(value); - - if (Array.isArray(value)) { - for (let i = 0; i < value.length; i++) { - validateValue(value[i], `${path}[${i}]`); + ancestors.add(value); + try { + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + validateValue(value[i], `${path}[${i}]`, ancestors); + } + return; } - return; - } - for (const [key, nestedValue] of Object.entries(value)) { - validateValue(nestedValue, `${path}.${key}`); + 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); + validateValue(value, key, new Set()); } } @@ -393,21 +535,50 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** - * Register an AbortSignal for cancellation support. - * Returns a cancellation ID that should be passed to methods accepting CancellationToken. + * 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 signal - The AbortSignal to register (optional) - * @returns The cancellation ID, or undefined if no signal provided + * @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: AspireClient, 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 or the token maps to CancellationToken.None + * + * @example + * const controller = new AbortController(); + * await expression.getValue(controller.signal); * * @example * const controller = new AbortController(); @@ -415,14 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signal?: AbortSignal): string | undefined { - if (!signal) { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + + if (!signalOrToken) { return undefined; } - // Already aborted? Don't register + if (signalOrToken instanceof CancellationToken) { + return signalOrToken.register(client); + } + + const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); + if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -430,8 +616,8 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -450,6 +636,56 @@ export function registerCancellation(signal?: AbortSignal): string | undefined { return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -480,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -491,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -501,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + if (this.connected) { + return Promise.resolve(); + } - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + 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.socket = net.createConnection(pipePath); + this._connectPromise = new Promise((resolve, reject) => { + const socket = net.createConnection(pipePath); + this.socket = socket; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -544,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -603,40 +936,65 @@ export class AspireClient { } validateCapabilityArgs(capabilityId, args); - - // 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++; + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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; + // Wrap handles automatically + return wrapIfHandle(result, this) as T; + } finally { + this._pendingCalls--; + if (this._pendingCalls === 0) { + this.socket?.unref(); + } + } } finally { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/apphost.ts index 4c04dc46299..74929927983 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/apphost.ts @@ -30,11 +30,17 @@ const keyVault = await builder.addAzureKeyVault('vault'); const appInsights = await builder.addAzureApplicationInsights('insights'); const cosmos = await builder.addAzureCosmosDB('cosmos'); const storage = await builder.addAzureStorage('storage'); +const search = await builder.addAzureSearch('search'); const project = await foundry.addProject('project'); await project.withContainerRegistry(registry); await project.withKeyVault(keyVault); await project.withAppInsights(appInsights); +await project.addCapabilityHost('cap-host'); +await project.withCapabilityHost(cosmos); +await project.withCapabilityHost(storage); +await project.withCapabilityHost(search); +await project.withCapabilityHost(foundry); const _cosmosConnection = await project.addCosmosConnection(cosmos); const _storageConnection = await project.addStorageConnection(storage); @@ -95,5 +101,6 @@ const _modelName = await chat.modelName.get(); const _format = await chat.format.get(); const _version = await chat.modelVersion.get(); const _connectionString = await chat.connectionStringExpression.get(); +const _deploymentParent = await chat.parent.get(); await builder.build().run(); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json new file mode 100644 index 00000000000..c6abb54b6af --- /dev/null +++ b/playground/polyglot/TypeScript/Aspire.Hosting.Foundry/ValidationAppHost/aspire.config.json @@ -0,0 +1,9 @@ +{ + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, + "packages": { + "Aspire.Hosting.Foundry": "" + } +} diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/.codegen-hash b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/.codegen-hash index 364f8c3f8c0..13044bba63f 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/.codegen-hash +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/.codegen-hash @@ -1 +1 @@ -32BF8F88017EC961588A68AB43A3333CED1BD44C5B4E482F4877C8DDB61F2A14 \ No newline at end of file +44D5C6496369336EC0DEADC85E5AF22C9C02FB662DAFE320AE8E74EA301B3466 \ No newline at end of file diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/aspire.ts b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/aspire.ts index 0f0e67c0f95..f95957763f0 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/aspire.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/aspire.ts @@ -424,6 +424,12 @@ export enum YarpSslProtocol { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -454,6 +460,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -576,6 +603,10 @@ export interface AddConnectionStringOptions { environmentVariableName?: string; } +export interface AddContainerRegistryFromStringOptions { + repository?: string; +} + export interface AddContainerRegistryOptions { repository?: ParameterResource; } @@ -593,6 +624,16 @@ export interface AddParameterOptions { secret?: boolean; } +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + +export interface AddParameterWithValueOptions { + publishValueAsDefault?: boolean; + secret?: boolean; +} + export interface AddRedisOptions { port?: number; password?: ParameterResource; @@ -693,6 +734,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDataBindMountOptions { isReadOnly?: boolean; } @@ -818,6 +865,7 @@ export interface WithRedisInsightOptions { export interface WithReferenceOptions { connectionName?: string; optional?: boolean; + name?: string; } export interface WithRequiredCommandOptions { @@ -4073,6 +4121,21 @@ export class DistributedApplicationBuilder { return new DistributedApplicationPromise(this._buildInternal()); } + /** Adds a connection string with a reference expression */ + /** @internal */ + async _addConnectionStringExpressionInternal(name: string, connectionStringExpression: ReferenceExpression): Promise { + const rpcArgs: Record = { builder: this._handle, name, connectionStringExpression }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addConnectionStringExpression', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._addConnectionStringExpressionInternal(name, connectionStringExpression)); + } + /** Adds a connection string with a builder callback */ /** @internal */ async _addConnectionStringBuilderInternal(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): Promise { @@ -4110,9 +4173,26 @@ export class DistributedApplicationBuilder { return new ContainerRegistryResourcePromise(this._addContainerRegistryInternal(name, endpoint, repository)); } + /** Adds a container registry with string endpoint */ + /** @internal */ + async _addContainerRegistryFromStringInternal(name: string, endpoint: string, repository?: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpoint }; + if (repository !== undefined) rpcArgs.repository = repository; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addContainerRegistryFromString', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + const repository = options?.repository; + return new ContainerRegistryResourcePromise(this._addContainerRegistryFromStringInternal(name, endpoint, repository)); + } + /** Adds a container resource */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { + 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', @@ -4121,7 +4201,7 @@ export class DistributedApplicationBuilder { return new ContainerResource(result, this._client); } - addContainer(name: string, image: string): ContainerResourcePromise { + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._addContainerInternal(name, image)); } @@ -4189,6 +4269,36 @@ export class DistributedApplicationBuilder { return new ExternalServiceResourcePromise(this._addExternalServiceInternal(name, url)); } + /** Adds an external service with a URI */ + /** @internal */ + async _addExternalServiceUriInternal(name: string, uri: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, uri }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceUri', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceUriInternal(name, uri)); + } + + /** Adds an external service with a parameter URL */ + /** @internal */ + async _addExternalServiceParameterInternal(name: string, urlParameter: ParameterResource): Promise { + const rpcArgs: Record = { builder: this._handle, name, urlParameter }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addExternalServiceParameter', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._addExternalServiceParameterInternal(name, urlParameter)); + } + /** Adds a parameter resource */ /** @internal */ async _addParameterInternal(name: string, secret?: boolean): Promise { @@ -4206,6 +4316,25 @@ export class DistributedApplicationBuilder { return new ParameterResourcePromise(this._addParameterInternal(name, secret)); } + /** Adds a parameter with a default value */ + /** @internal */ + async _addParameterWithValueInternal(name: string, value: string, publishValueAsDefault?: boolean, secret?: boolean): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; + if (publishValueAsDefault !== undefined) rpcArgs.publishValueAsDefault = publishValueAsDefault; + if (secret !== undefined) rpcArgs.secret = secret; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addParameterWithValue', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + const publishValueAsDefault = options?.publishValueAsDefault; + const secret = options?.secret; + return new ParameterResourcePromise(this._addParameterWithValueInternal(name, value, publishValueAsDefault, secret)); + } + /** Adds a parameter sourced from configuration */ /** @internal */ async _addParameterFromConfigurationInternal(name: string, configurationKey: string, secret?: boolean): Promise { @@ -4223,6 +4352,25 @@ export class DistributedApplicationBuilder { return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); } + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + /** Adds a connection string resource */ /** @internal */ async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { @@ -4240,6 +4388,21 @@ export class DistributedApplicationBuilder { return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); } + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + /** Adds a .NET project resource */ /** @internal */ async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { @@ -4424,6 +4587,11 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.build())); } + /** Adds a connection string with a reference expression */ + addConnectionStringExpression(name: string, connectionStringExpression: ReferenceExpression): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringExpression(name, connectionStringExpression))); + } + /** Adds a connection string with a builder callback */ addConnectionStringBuilder(name: string, connectionStringBuilder: (obj: ReferenceExpressionBuilder) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.addConnectionStringBuilder(name, connectionStringBuilder))); @@ -4434,8 +4602,13 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addContainerRegistry(name, endpoint, options))); } + /** Adds a container registry with string endpoint */ + addContainerRegistryFromString(name: string, endpoint: string, options?: AddContainerRegistryFromStringOptions): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.addContainerRegistryFromString(name, endpoint, options))); + } + /** Adds a container resource */ - addContainer(name: string, image: string): ContainerResourcePromise { + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.addContainer(name, image))); } @@ -4459,21 +4632,46 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addExternalService(name, url))); } + /** Adds an external service with a URI */ + addExternalServiceUri(name: string, uri: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceUri(name, uri))); + } + + /** Adds an external service with a parameter URL */ + addExternalServiceParameter(name: string, urlParameter: ParameterResource): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.addExternalServiceParameter(name, urlParameter))); + } + /** Adds a parameter resource */ addParameter(name: string, options?: AddParameterOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.addParameter(name, options))); } + /** Adds a parameter with a default value */ + addParameterWithValue(name: string, value: string, options?: AddParameterWithValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithValue(name, value, options))); + } + /** Adds a parameter sourced from configuration */ addParameterFromConfiguration(name: string, configurationKey: string, options?: AddParameterFromConfigurationOptions): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterFromConfiguration(name, configurationKey, options))); } + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + /** Adds a connection string resource */ addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); } + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + /** Adds a .NET project resource */ addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); @@ -5735,7 +5933,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -5744,8 +5942,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', + rpcArgs + ); + } + /** @internal */ private async _withUrlsCallbackInternal(callback: (obj: ResourceUrlsCallbackContext) => Promise): Promise { const callbackId = registerCallback(async (objData: unknown) => { @@ -5876,7 +6083,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5906,7 +6113,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -5952,7 +6159,7 @@ export class ConnectionStringResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -6001,11 +6208,26 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -6020,7 +6242,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ConnectionStringResource(result, this._client); @@ -6272,8 +6494,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -6282,6 +6504,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Customizes displayed URLs via callback */ withUrlsCallback(callback: (obj: ResourceUrlsCallbackContext) => Promise): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withUrlsCallback(callback))); @@ -6352,6 +6579,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6639,11 +6871,26 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -6658,7 +6905,7 @@ export class ContainerRegistryResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerRegistryResource(result, this._client); @@ -6935,6 +7182,11 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -7210,7 +7462,7 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -7219,8 +7471,8 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new ContainerResource(result, this._client); @@ -7239,6 +7491,27 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -7370,41 +7643,11 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -7415,43 +7658,38 @@ export class ContainerResource extends ResourceBuilderBase Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { - return new ContainerResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -7540,52 +7778,39 @@ export class ContainerResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ContainerResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ContainerResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -7885,7 +8110,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ContainerResource(result, this._client); @@ -7915,7 +8140,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ContainerResource(result, this._client); @@ -7961,7 +8186,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ContainerResource(result, this._client); @@ -8066,7 +8291,7 @@ export class ContainerResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ContainerResource(result, this._client); @@ -8093,11 +8318,26 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -8112,7 +8352,7 @@ export class ContainerResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ContainerResource(result, this._client); @@ -8492,8 +8732,8 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -8502,6 +8742,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -8542,31 +8787,21 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -8592,21 +8827,16 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ContainerResourcePromise { - return new ContainerResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -8752,6 +8982,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -9001,43 +9236,13 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); + }); + const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withEnvironmentCallback', rpcArgs @@ -9046,43 +9251,38 @@ export class CSharpAppResource extends ResourceBuilderBase Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -9171,52 +9371,39 @@ export class CSharpAppResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new CSharpAppResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new CSharpAppResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new CSharpAppResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -9501,7 +9688,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9531,7 +9718,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9561,7 +9748,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9607,7 +9794,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9712,7 +9899,7 @@ export class CSharpAppResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9739,11 +9926,26 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -9758,7 +9960,7 @@ export class CSharpAppResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new CSharpAppResource(result, this._client); @@ -10099,31 +10301,21 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -10149,21 +10341,16 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): CSharpAppResourcePromise { - return new CSharpAppResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -10314,6 +10501,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -10661,41 +10853,11 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -10706,43 +10868,38 @@ export class DotnetToolResource extends ResourceBuilderBase Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -10831,52 +10988,39 @@ export class DotnetToolResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new DotnetToolResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new DotnetToolResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new DotnetToolResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -11176,7 +11320,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11206,7 +11350,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11252,7 +11396,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11357,7 +11501,7 @@ export class DotnetToolResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11384,11 +11528,26 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11403,7 +11562,7 @@ export class DotnetToolResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new DotnetToolResource(result, this._client); @@ -11779,31 +11938,21 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -11829,21 +11978,16 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): DotnetToolResourcePromise { - return new DotnetToolResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -11989,6 +12133,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -12246,41 +12395,11 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -12291,43 +12410,38 @@ export class ExecutableResource extends ResourceBuilderBase Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -12416,52 +12530,39 @@ export class ExecutableResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ExecutableResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ExecutableResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ExecutableResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -12761,7 +12862,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12791,7 +12892,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12837,7 +12938,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12942,7 +13043,7 @@ export class ExecutableResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12969,11 +13070,26 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -12988,7 +13104,7 @@ export class ExecutableResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExecutableResource(result, this._client); @@ -13334,31 +13450,21 @@ export class ExecutableResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -13384,21 +13490,16 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ExecutableResourcePromise { - return new ExecutableResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -13544,6 +13645,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -13865,11 +13971,26 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -13884,7 +14005,7 @@ export class ExternalServiceResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ExternalServiceResource(result, this._client); @@ -14166,6 +14287,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14465,11 +14591,26 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -14484,7 +14625,7 @@ export class ParameterResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ParameterResource(result, this._client); @@ -14766,6 +14907,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14990,41 +15136,11 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -15035,43 +15151,38 @@ export class ProjectResource extends ResourceBuilderBase } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { - return new ProjectResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -15160,52 +15271,39 @@ export class ProjectResource extends ResourceBuilderBase } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ProjectResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ProjectResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ProjectResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -15490,7 +15588,7 @@ export class ProjectResource extends ResourceBuilderBase private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -15520,7 +15618,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ProjectResource(result, this._client); @@ -15550,7 +15648,7 @@ export class ProjectResource extends ResourceBuilderBase private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ProjectResource(result, this._client); @@ -15596,7 +15694,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ProjectResource(result, this._client); @@ -15701,7 +15799,7 @@ export class ProjectResource extends ResourceBuilderBase const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ProjectResource(result, this._client); @@ -15728,11 +15826,26 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -15747,7 +15860,7 @@ export class ProjectResource extends ResourceBuilderBase private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new ProjectResource(result, this._client); @@ -16088,31 +16201,21 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -16138,21 +16241,16 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ProjectResourcePromise { - return new ProjectResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -16303,6 +16401,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16598,7 +16701,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -16607,8 +16710,8 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -16627,6 +16730,27 @@ export class RedisCommanderResource extends ResourceBuilderBase { + 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 RedisCommanderResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisCommanderResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -16758,41 +16882,11 @@ export class RedisCommanderResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -16803,43 +16897,38 @@ export class RedisCommanderResource extends ResourceBuilderBase Promise): RedisCommanderResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -16928,52 +17017,39 @@ export class RedisCommanderResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisCommanderResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new RedisCommanderResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new RedisCommanderResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new RedisCommanderResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisCommanderResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisCommanderResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -17273,7 +17349,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -17303,7 +17379,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -17349,7 +17425,7 @@ export class RedisCommanderResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -17454,7 +17530,7 @@ export class RedisCommanderResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -17481,11 +17557,26 @@ export class RedisCommanderResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisCommanderResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -17500,7 +17591,7 @@ export class RedisCommanderResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisCommanderResource(result, this._client); @@ -17897,8 +17988,8 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisCommanderResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -17907,6 +17998,11 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -17947,31 +18043,21 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -17997,21 +18083,16 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisCommanderResourcePromise { - return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -18157,6 +18238,11 @@ export class RedisCommanderResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisCommanderResourcePromise { + return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisCommanderResourcePromise { return new RedisCommanderResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -18462,7 +18548,7 @@ export class RedisInsightResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -18471,8 +18557,8 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -18491,6 +18577,27 @@ export class RedisInsightResource extends ResourceBuilderBase { + 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 RedisInsightResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisInsightResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -18622,41 +18729,11 @@ export class RedisInsightResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -18667,43 +18744,38 @@ export class RedisInsightResource extends ResourceBuilderBase Promise): RedisInsightResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -18792,52 +18864,39 @@ export class RedisInsightResource extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisInsightResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new RedisInsightResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new RedisInsightResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new RedisInsightResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisInsightResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisInsightResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -19137,7 +19196,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -19167,7 +19226,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -19213,7 +19272,7 @@ export class RedisInsightResource extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -19318,7 +19377,7 @@ export class RedisInsightResource extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -19345,11 +19404,26 @@ export class RedisInsightResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisInsightResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -19364,7 +19438,7 @@ export class RedisInsightResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisInsightResource(result, this._client); @@ -19793,8 +19867,8 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisInsightResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -19803,6 +19877,11 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -19843,31 +19922,21 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -19893,21 +19962,16 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisInsightResourcePromise { - return new RedisInsightResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -20053,6 +20117,11 @@ export class RedisInsightResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisInsightResourcePromise { + return new RedisInsightResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisInsightResourcePromise { return new RedisInsightResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -20484,7 +20553,7 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -20493,8 +20562,8 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResource(result, this._client); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisResourcePromise { return new RedisResourcePromise(this._withBuildArgInternal(name, value)); } @@ -20502,7 +20571,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new RedisResource(result, this._client); @@ -20513,6 +20582,27 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withBuildSecretInternal(name, value)); } + /** @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 RedisResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new RedisResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -20644,41 +20734,11 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new RedisResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new RedisResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -20689,43 +20749,38 @@ export class RedisResource extends ResourceBuilderBase { } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { return new RedisResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new RedisResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { - return new RedisResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisResourcePromise { + return new RedisResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -20759,7 +20814,7 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withConnectionPropertyInternal(name: string, value: ReferenceExpression): Promise { + 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', @@ -20768,8 +20823,8 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResource(result, this._client); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): RedisResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise { return new RedisResourcePromise(this._withConnectionPropertyInternal(name, value)); } @@ -20844,52 +20899,48 @@ export class RedisResource extends ResourceBuilderBase { } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new RedisResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new RedisResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise { + return new RedisResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', + 'Aspire.Hosting/withReference', rpcArgs ); return new RedisResource(result, this._client); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisResourcePromise { - return new RedisResourcePromise(this._withServiceReferenceInternal(source)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new RedisResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + /** Gets a connection property by key */ + async getConnectionProperty(key: string): Promise { + const rpcArgs: Record = { resource: this._handle, key }; + return await this._client.invokeCapability( + 'Aspire.Hosting/getConnectionProperty', rpcArgs ); - return new RedisResource(result, this._client); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisResourcePromise { - return new RedisResourcePromise(this._withServiceReferenceNamedInternal(source, name)); } /** @internal */ @@ -21189,7 +21240,7 @@ export class RedisResource extends ResourceBuilderBase { private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new RedisResource(result, this._client); @@ -21219,7 +21270,7 @@ export class RedisResource extends ResourceBuilderBase { private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new RedisResource(result, this._client); @@ -21265,7 +21316,7 @@ export class RedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new RedisResource(result, this._client); @@ -21370,7 +21421,7 @@ export class RedisResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new RedisResource(result, this._client); @@ -21397,11 +21448,26 @@ export class RedisResource extends ResourceBuilderBase { return new RedisResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new RedisResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisResourcePromise { + return new RedisResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new RedisResource(result, this._client); @@ -21416,7 +21482,7 @@ export class RedisResource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new RedisResource(result, this._client); @@ -21951,8 +22017,8 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): RedisResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -21961,6 +22027,11 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -22001,31 +22072,21 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): RedisResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -22036,8 +22097,8 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): RedisResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -22061,19 +22122,19 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): RedisResourcePromise { - return new RedisResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); } /** Adds a reference to a URI */ @@ -22221,6 +22282,11 @@ export class RedisResourcePromise implements PromiseLike { return new RedisResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): RedisResourcePromise { + return new RedisResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): RedisResourcePromise { return new RedisResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -22561,7 +22627,7 @@ export class YarpResource extends ResourceBuilderBase { } /** @internal */ - private async _withBuildArgInternal(name: string, value: ParameterResource): Promise { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( 'Aspire.Hosting/withBuildArg', @@ -22570,8 +22636,8 @@ export class YarpResource extends ResourceBuilderBase { return new YarpResource(result, this._client); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): YarpResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): YarpResourcePromise { return new YarpResourcePromise(this._withBuildArgInternal(name, value)); } @@ -22579,7 +22645,7 @@ export class YarpResource extends ResourceBuilderBase { private async _withBuildSecretInternal(name: string, value: ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withBuildSecret', + 'Aspire.Hosting/withParameterBuildSecret', rpcArgs ); return new YarpResource(result, this._client); @@ -22590,6 +22656,27 @@ export class YarpResource extends ResourceBuilderBase { return new YarpResourcePromise(this._withBuildSecretInternal(name, value)); } + /** @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 YarpResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): YarpResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new YarpResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -22721,41 +22808,11 @@ export class YarpResource extends ResourceBuilderBase { } /** @internal */ - private async _withEnvironmentInternal(name: string, value: string): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new YarpResource(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): YarpResourcePromise { - return new YarpResourcePromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new YarpResource(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): YarpResourcePromise { - return new YarpResourcePromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -22766,43 +22823,38 @@ export class YarpResource extends ResourceBuilderBase { } /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): YarpResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): YarpResourcePromise { return new YarpResourcePromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new YarpResource(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): YarpResourcePromise { - return new YarpResourcePromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): YarpResourcePromise { + return new YarpResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new YarpResource(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): YarpResourcePromise { - return new YarpResourcePromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): YarpResourcePromise { + return new YarpResourcePromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -22891,52 +22943,39 @@ export class YarpResource extends ResourceBuilderBase { } /** @internal */ - private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean): Promise { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new YarpResource(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): YarpResourcePromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new YarpResourcePromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): YarpResourcePromise { + return new YarpResourcePromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new YarpResource(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): YarpResourcePromise { - return new YarpResourcePromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new YarpResource(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): YarpResourcePromise { - return new YarpResourcePromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): YarpResourcePromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new YarpResourcePromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -23221,7 +23260,7 @@ export class YarpResource extends ResourceBuilderBase { private async _publishWithContainerFilesInternal(source: ResourceBuilderBase, destinationPath: string): Promise { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new YarpResource(result, this._client); @@ -23251,7 +23290,7 @@ export class YarpResource extends ResourceBuilderBase { private async _waitForInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new YarpResource(result, this._client); @@ -23281,7 +23320,7 @@ export class YarpResource extends ResourceBuilderBase { private async _waitForStartInternal(dependency: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new YarpResource(result, this._client); @@ -23327,7 +23366,7 @@ export class YarpResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new YarpResource(result, this._client); @@ -23432,7 +23471,7 @@ export class YarpResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new YarpResource(result, this._client); @@ -23459,11 +23498,26 @@ export class YarpResource extends ResourceBuilderBase { return new YarpResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new YarpResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): YarpResourcePromise { + return new YarpResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new YarpResource(result, this._client); @@ -23478,7 +23532,7 @@ export class YarpResource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new YarpResource(result, this._client); @@ -23942,8 +23996,8 @@ export class YarpResourcePromise implements PromiseLike { return new YarpResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): YarpResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -23952,6 +24006,11 @@ export class YarpResourcePromise implements PromiseLike { return new YarpResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): YarpResourcePromise { + return new YarpResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -23992,31 +24051,21 @@ export class YarpResourcePromise implements PromiseLike { return new YarpResourcePromise(this._promise.then(obj => obj.withRequiredCommand(command, options))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): YarpResourcePromise { - return new YarpResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): YarpResourcePromise { - return new YarpResourcePromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): YarpResourcePromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): YarpResourcePromise { - return new YarpResourcePromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): YarpResourcePromise { + return new YarpResourcePromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -24042,21 +24091,16 @@ export class YarpResourcePromise implements PromiseLike { return new YarpResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): YarpResourcePromise { + return new YarpResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): YarpResourcePromise { - return new YarpResourcePromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): YarpResourcePromise { - return new YarpResourcePromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -24207,6 +24251,11 @@ export class YarpResourcePromise implements PromiseLike { return new YarpResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): YarpResourcePromise { + return new YarpResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): YarpResourcePromise { return new YarpResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -24400,7 +24449,7 @@ export class ContainerFilesDestinationResource extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, source, destinationPath }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/publishWithContainerFiles', + 'Aspire.Hosting/publishWithContainerFilesFromResource', rpcArgs ); return new ContainerFilesDestinationResource(result, this._client); @@ -24655,11 +24704,26 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParentRelationship', + 'Aspire.Hosting/withBuilderParentRelationship', rpcArgs ); return new Resource(result, this._client); @@ -24674,7 +24738,7 @@ export class Resource extends ResourceBuilderBase { private async _withChildRelationshipInternal(child: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, child }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withChildRelationship', + 'Aspire.Hosting/withBuilderChildRelationship', rpcArgs ); return new Resource(result, this._client); @@ -24951,6 +25015,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -25121,7 +25190,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -25130,8 +25199,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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) => { @@ -25187,8 +25265,8 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionProperty(name, value))); } @@ -25197,6 +25275,11 @@ export class ResourceWithConnectionStringPromise implements PromiseLike obj.withConnectionPropertyValue(name, value))); } + /** Gets a connection property by key */ + getConnectionProperty(key: string): Promise { + return this._promise.then(obj => obj.getConnectionProperty(key)); + } + /** Subscribes to the ConnectionStringAvailable event */ onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.onConnectionStringAvailable(callback))); @@ -25624,41 +25707,11 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironment', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentExpressionInternal(name: string, value: ReferenceExpression): Promise { - const rpcArgs: Record = { builder: this._handle, name, value }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentExpression', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentExpressionInternal(name, value)); - } - - /** @internal */ - private async _withEnvironmentCallbackInternal(callback: (obj: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (objData: unknown) => { - const objHandle = wrapIfHandle(objData) as EnvironmentCallbackContextHandle; - const obj = new EnvironmentCallbackContext(objHandle, this._client); - await callback(obj); + private async _withEnvironmentCallbackInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { + const callbackId = registerCallback(async (argData: unknown) => { + const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; + const arg = new EnvironmentCallbackContext(argHandle, this._client); + await callback(arg); }); const rpcArgs: Record = { builder: this._handle, callback: callbackId }; const result = await this._client.invokeCapability( @@ -25669,43 +25722,38 @@ export class ResourceWithEnvironment extends ResourceBuilderBase Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackInternal(callback)); } /** @internal */ - private async _withEnvironmentCallbackAsyncInternal(callback: (arg: EnvironmentCallbackContext) => Promise): Promise { - const callbackId = registerCallback(async (argData: unknown) => { - const argHandle = wrapIfHandle(argData) as EnvironmentCallbackContextHandle; - const arg = new EnvironmentCallbackContext(argHandle, this._client); - await callback(arg); - }); - const rpcArgs: Record = { builder: this._handle, callback: callbackId }; + private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { + const rpcArgs: Record = { builder: this._handle, name, endpointReference }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentCallbackAsync', + 'Aspire.Hosting/withEnvironmentEndpoint', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentCallbackAsyncInternal(callback)); + /** Sets an environment variable from an endpoint reference */ + withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); } /** @internal */ - private async _withEnvironmentEndpointInternal(name: string, endpointReference: EndpointReference): Promise { - const rpcArgs: Record = { builder: this._handle, name, endpointReference }; + private async _withEnvironmentInternal(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): Promise { + const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withEnvironmentEndpoint', + 'Aspire.Hosting/withEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Sets an environment variable from an endpoint reference */ - withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withEnvironmentEndpointInternal(name, endpointReference)); + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withEnvironmentInternal(name, value)); } /** @internal */ @@ -25739,52 +25787,39 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { - const rpcArgs: Record = { builder: this._handle, source }; - if (connectionName !== undefined) rpcArgs.connectionName = connectionName; - if (optional !== undefined) rpcArgs.optional = optional; + private async _withReferenceEnvironmentInternal(options: ReferenceEnvironmentInjectionOptions): Promise { + const rpcArgs: Record = { builder: this._handle, options }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withReference', + 'Aspire.Hosting/withReferenceEnvironment', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a reference to another resource */ - withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { - const connectionName = options?.connectionName; - const optional = options?.optional; - return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional)); + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); } /** @internal */ - private async _withServiceReferenceInternal(source: ResourceBuilderBase): Promise { + private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { 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/withServiceReference', - rpcArgs - ); - return new ResourceWithEnvironment(result, this._client); - } - - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceInternal(source)); - } - - /** @internal */ - private async _withServiceReferenceNamedInternal(source: ResourceBuilderBase, name: string): Promise { - const rpcArgs: Record = { builder: this._handle, source, name }; - const result = await this._client.invokeCapability( - 'Aspire.Hosting/withServiceReferenceNamed', + 'Aspire.Hosting/withReference', rpcArgs ); return new ResourceWithEnvironment(result, this._client); } - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._withServiceReferenceNamedInternal(source, name)); + /** Adds a reference to another resource */ + withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { + const connectionName = options?.connectionName; + const optional = options?.optional; + const name = options?.name; + return new ResourceWithEnvironmentPromise(this._withReferenceInternal(source, connectionName, optional, name)); } /** @internal */ @@ -25867,7 +25902,7 @@ export class ResourceWithEnvironment extends ResourceBuilderBase = { builder: this._handle }; if (password !== undefined) rpcArgs.password = password; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withHttpsDeveloperCertificate', + 'Aspire.Hosting/withParameterHttpsDeveloperCertificate', rpcArgs ); return new ResourceWithEnvironment(result, this._client); @@ -25921,31 +25956,21 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withOtlpExporterProtocol(protocol))); } - /** Sets an environment variable */ - withEnvironment(name: string, value: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); - } - - /** Adds an environment variable with a reference expression */ - withEnvironmentExpression(name: string, value: ReferenceExpression): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentExpression(name, value))); - } - /** Sets environment variables via callback */ - withEnvironmentCallback(callback: (obj: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { + withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallback(callback))); } - /** Sets environment variables via async callback */ - withEnvironmentCallbackAsync(callback: (arg: EnvironmentCallbackContext) => Promise): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentCallbackAsync(callback))); - } - /** Sets an environment variable from an endpoint reference */ withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentEndpoint(name, endpointReference))); } + /** Sets an environment variable on the resource */ + withEnvironment(name: string, value: string | ReferenceExpression | EndpointReference | ParameterResource | ResourceWithConnectionString): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironment(name, value))); + } + /** Sets an environment variable from a parameter resource */ withEnvironmentParameter(name: string, parameter: ParameterResource): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withEnvironmentParameter(name, parameter))); @@ -25956,21 +25981,16 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); } - /** Adds a service discovery reference to another resource */ - withServiceReference(source: ResourceBuilderBase): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReference(source))); - } - - /** Adds a named service discovery reference */ - withServiceReferenceNamed(source: ResourceBuilderBase, name: string): ResourceWithEnvironmentPromise { - return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withServiceReferenceNamed(source, name))); - } - /** Adds a reference to a URI */ withReferenceUri(name: string, uri: string): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceUri(name, uri))); @@ -26049,7 +26069,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitFor', + 'Aspire.Hosting/waitForResource', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -26079,7 +26099,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase { const rpcArgs: Record = { builder: this._handle, dependency }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForStart', + 'Aspire.Hosting/waitForResourceStart', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); @@ -26110,7 +26130,7 @@ export class ResourceWithWaitSupport extends ResourceBuilderBase = { builder: this._handle, dependency }; if (exitCode !== undefined) rpcArgs.exitCode = exitCode; const result = await this._client.invokeCapability( - 'Aspire.Hosting/waitForCompletion', + 'Aspire.Hosting/waitForResourceCompletion', rpcArgs ); return new ResourceWithWaitSupport(result, this._client); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/base.ts b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/base.ts index 0aceb7ba897..b3d8b8be98c 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/base.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/base.ts @@ -1,4 +1,4 @@ -// aspire.ts - Core Aspire types: base classes, ReferenceExpression +// base.ts - Core Aspire types: base classes, ReferenceExpression import { Handle, AspireClient, MarshalledHandle, CancellationToken, registerCancellation, registerHandleWrapper, unregisterCancellation } from './transport.js'; // Re-export transport types for convenience @@ -165,7 +165,7 @@ export class ReferenceExpression { if (!this._handle || !this._client) { throw new Error('getValue is only available on server-returned ReferenceExpression instances'); } - const cancellationTokenId = registerCancellation(cancellationToken); + const cancellationTokenId = registerCancellation(this._client, cancellationToken); try { const rpcArgs: Record = { context: this._handle }; if (cancellationTokenId !== undefined) rpcArgs.cancellationToken = cancellationTokenId; @@ -392,11 +392,20 @@ export class AspireList { }) as T[]; } - toJSON(): MarshalledHandle { - if (this._resolvedHandle) { - return this._resolvedHandle.toJSON(); + 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._handleOrContext.toJSON(); + + return this._resolvedHandle.toJSON(); } } @@ -551,8 +560,19 @@ export class AspireDict { }) as Record; } - async toJSON(): Promise { + 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(); + } } diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/transport.ts b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/transport.ts index 50219ab6f54..6d29cf289d9 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/transport.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.modules/transport.ts @@ -77,7 +77,8 @@ export function isAtsError(value: unknown): value is { $error: AtsError } { value !== null && typeof value === 'object' && '$error' in value && - typeof (value as { $error: unknown }).$error === 'object' + typeof (value as { $error: unknown }).$error === 'object' && + (value as { $error: unknown }).$error !== null ); } @@ -103,6 +104,37 @@ function isAbortSignal(value: unknown): value is AbortSignal { ); } +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 // ============================================================================ @@ -176,7 +208,6 @@ export class Handle { export class CancellationToken { private readonly _signal?: AbortSignal; private readonly _remoteTokenId?: string; - private _registeredTokenId?: string; constructor(signal?: AbortSignal); constructor(tokenId?: string); @@ -219,16 +250,17 @@ export class CancellationToken { * Serializes the token for JSON-RPC transport. */ toJSON(): string | undefined { - if (this._remoteTokenId) { - return this._remoteTokenId; - } + return this._remoteTokenId; + } - if (this._registeredTokenId !== undefined) { - return this._registeredTokenId; + register(client?: AspireClient): string | undefined { + if (this._remoteTokenId !== undefined) { + return this._remoteTokenId; } - this._registeredTokenId = registerCancellation(this._signal); - return this._registeredTokenId; + return client + ? registerCancellation(client, this._signal) + : registerCancellation(this._signal); } } @@ -263,22 +295,35 @@ export function registerHandleWrapper(typeId: string, factory: HandleWrapperFact * @param client - Optional client for creating typed wrapper instances */ export function wrapIfHandle(value: unknown, client?: AspireClient): unknown { - if (value && typeof value === 'object') { - 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); - } + 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; + } - 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; } @@ -336,9 +381,7 @@ function validateCapabilityArgs( return; } - const seen = new Set(); - - const validateValue = (value: unknown, path: string): void => { + const validateValue = (value: unknown, path: string, ancestors: Set): void => { if (value === null || value === undefined) { return; } @@ -355,26 +398,29 @@ function validateCapabilityArgs( return; } - if (seen.has(value)) { - return; + if (ancestors.has(value)) { + throw createCircularReferenceError(capabilityId, path); } - seen.add(value); - - if (Array.isArray(value)) { - for (let i = 0; i < value.length; i++) { - validateValue(value[i], `${path}[${i}]`); + ancestors.add(value); + try { + if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + validateValue(value[i], `${path}[${i}]`, ancestors); + } + return; } - return; - } - for (const [key, nestedValue] of Object.entries(value)) { - validateValue(nestedValue, `${path}.${key}`); + 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); + validateValue(value, key, new Set()); } } @@ -489,12 +535,29 @@ export function getCallbackCount(): number { */ const cancellationRegistry = new Map void>(); let cancellationIdCounter = 0; +const connectedClients = new Set(); -/** - * A reference to the current AspireClient for sending cancel requests. - * Set by AspireClient.connect(). - */ -let currentClient: AspireClient | null = null; +function resolveCancellationClient(client?: AspireClient): AspireClient { + 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.' + ); +} /** * Registers cancellation support for a local signal or SDK cancellation token. @@ -502,6 +565,14 @@ let currentClient: AspireClient | null = null; * * 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: AspireClient, 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 or the token maps to CancellationToken.None * @@ -515,20 +586,29 @@ let currentClient: AspireClient | null = null; * // Pass id to capability invocation * // Later: controller.abort() will cancel the operation */ -export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined { +export function registerCancellation(signalOrToken?: AbortSignal | CancellationToken): string | undefined; +export function registerCancellation( + clientOrSignalOrToken?: AspireClient | AbortSignal | CancellationToken, + maybeSignalOrToken?: AbortSignal | CancellationToken +): string | undefined { + const client = clientOrSignalOrToken instanceof AspireClient ? clientOrSignalOrToken : undefined; + const signalOrToken = client + ? maybeSignalOrToken + : clientOrSignalOrToken as AbortSignal | CancellationToken | undefined; + if (!signalOrToken) { return undefined; } if (signalOrToken instanceof CancellationToken) { - return signalOrToken.toJSON(); + return signalOrToken.register(client); } const signal = signalOrToken; + const cancellationClient = resolveCancellationClient(client); - // Already aborted? Don't register if (signal.aborted) { - return undefined; + throw createAbortError('The operation was aborted before it was sent to the AppHost.'); } const cancellationId = `ct_${++cancellationIdCounter}_${Date.now()}`; @@ -536,8 +616,8 @@ export function registerCancellation(signalOrToken?: AbortSignal | CancellationT // Set up the abort listener const onAbort = () => { // Send cancel request to host - if (currentClient?.connected) { - currentClient.cancelToken(cancellationId).catch(() => { + if (cancellationClient.connected) { + cancellationClient.cancelToken(cancellationId).catch(() => { // Ignore errors - the operation may have already completed }); } @@ -556,6 +636,56 @@ export function registerCancellation(signalOrToken?: AbortSignal | CancellationT return cancellationId; } +async function marshalTransportValue( + value: unknown, + client: AspireClient, + cancellationIds: string[], + capabilityId: string, + path: string = 'args', + ancestors: Set = new Set() +): Promise { + if (value === null || value === undefined || typeof value !== 'object') { + return value; + } + + if (value instanceof CancellationToken) { + 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. @@ -586,6 +716,8 @@ export class AspireClient { private socket: net.Socket | null = null; private disconnectCallbacks: (() => void)[] = []; private _pendingCalls = 0; + private _connectPromise: Promise | null = null; + private _disconnectNotified = false; constructor(private socketPath: string) { } @@ -597,6 +729,12 @@ export class AspireClient { } private notifyDisconnect(): void { + if (this._disconnectNotified) { + return; + } + + this._disconnectNotified = true; + for (const callback of this.disconnectCallbacks) { try { callback(); @@ -607,30 +745,106 @@ export class AspireClient { } connect(timeoutMs: number = 5000): Promise { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => reject(new Error('Connection timeout')), timeoutMs); + 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; - // On Windows, use named pipes; on Unix, use Unix domain sockets - const isWindows = process.platform === 'win32'; - const pipePath = isWindows ? `\\\\.\\pipe\\${this.socketPath}` : this.socketPath; + let settled = false; - this.socket = net.createConnection(pipePath); + const cleanupPendingListeners = () => { + socket.removeListener('connect', onConnect); + socket.removeListener('error', onPendingError); + socket.removeListener('close', onPendingClose); + }; - this.socket.once('error', (error: Error) => { + 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; + } - this.socket.once('connect', () => { clearTimeout(timeout); + cleanupPendingListeners(); + try { - const reader = new rpc.SocketMessageReader(this.socket!); - const writer = new rpc.SocketMessageWriter(this.socket!); + 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.notifyDisconnect(); }); this.connection.onError((err: any) => console.error('JsonRpc connection error:', err)); @@ -650,26 +864,39 @@ export class AspireClient { } }); + 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.'); + } - // Set the current client for cancellation registry - currentClient = this; + connectedClients.add(this); + this._connectPromise = null; + settled = true; resolve(); - } catch (e) { - reject(e); + } catch (error) { + failConnect(error instanceof Error ? error : new Error(String(error))); } - }); + }; - this.socket.on('close', () => { - this.connection?.dispose(); - this.connection = null; - if (currentClient === this) { - currentClient = null; - } - this.notifyDisconnect(); - }); + 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 { @@ -709,40 +936,65 @@ export class AspireClient { } validateCapabilityArgs(capabilityId, args); - - // 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++; + const cancellationIds: string[] = []; try { - const result = await this.connection.sendRequest( - 'invokeCapability', - capabilityId, - args ?? null - ); + const rpcArgs = await marshalTransportValue(args ?? null, this, cancellationIds, capabilityId); - // Check for structured error response - if (isAtsError(result)) { - throw new CapabilityError(result.$error); + // 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++; - // Wrap handles automatically - return wrapIfHandle(result, this) as T; + 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 { - this._pendingCalls--; - if (this._pendingCalls === 0) { - this.socket?.unref(); + for (const cancellationId of cancellationIds) { + unregisterCancellation(cancellationId); } } } disconnect(): void { - try { this.connection?.dispose(); } finally { this.connection = null; } - try { this.socket?.end(); } finally { this.socket = null; } + 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 { diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts index fabecdca04a..1a306a17782 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts @@ -14,6 +14,10 @@ const builder = await createBuilder(); // addContainer (pre-existing) const container = await builder.addContainer("mycontainer", "nginx"); +const taggedContainer = await builder.addContainer("mytaggedcontainer", { + image: "nginx", + tag: "stable-alpine", +}); // addDockerfile const dockerContainer = await builder.addDockerfile("dockerapp", "./app"); @@ -23,6 +27,13 @@ const exe = await builder.addExecutable("myexe", "echo", ".", ["hello"]); // addProject (pre-existing) const project = await builder.addProject("myproject", "./src/MyProject", "https"); +const projectWithoutLaunchProfile = await builder.addProjectWithoutLaunchProfile("myproject-noprofile", "./src/MyProject"); +// ATS exports ReferenceEnvironmentInjectionFlags as a DTO-shaped object in TypeScript. +const referenceEnvironmentOptions = { + connectionString: true, + serviceDiscovery: true, +}; +await project.withReferenceEnvironment(referenceEnvironmentOptions); // addCSharpApp const csharpApp = await builder.addCSharpApp("csharpapp", "./src/CSharpApp"); @@ -36,6 +47,18 @@ const tool = await builder.addDotnetTool("mytool", "dotnet-ef"); // addParameterFromConfiguration const configParam = await builder.addParameterFromConfiguration("myconfig", "MyConfig:Key"); const secretParam = await builder.addParameterFromConfiguration("mysecret", "MyConfig:Secret", { secret: true }); +const generatedParam = await builder.addParameterWithGeneratedValue("generated-secret", { + minLength: 24, + lower: true, + upper: true, + numeric: true, + special: false, + minUpper: 2, + minNumeric: 2, +}, { + secret: true, + persist: true, +}); // =================================================================== // Container-specific methods on ContainerResource @@ -43,6 +66,13 @@ const secretParam = await builder.addParameterFromConfiguration("mysecret", "MyC // withDockerfileBaseImage await container.withDockerfileBaseImage({ buildImage: "mcr.microsoft.com/dotnet/sdk:8.0" }); +await dockerContainer.withBuildArg("STATIC_BRANDING", "/app/static/branding/custom"); +await dockerContainer.withBuildArg("CONFIG_BRANDING", configParam); +await container.withContainerCertificatePaths({ + customCertificatesDestination: "/usr/lib/ssl/aspire/custom", + defaultCertificateBundlePaths: ["/etc/ssl/certs/ca-certificates.crt"], + defaultCertificateDirectoryPaths: ["/etc/ssl/certs", "/usr/local/share/ca-certificates"], +}); // withContainerRegistry await container.withContainerRegistry(container); @@ -67,7 +97,7 @@ const builtConnectionString = await builder.addConnectionStringBuilder("customcs }); await builtConnectionString.withConnectionProperty("Host", expr); -await builtConnectionString.withConnectionPropertyValue("Mode", "Development"); +await builtConnectionString.withConnectionProperty("Mode", "Development"); const envConnectionString = await builder.addConnectionString("envcs"); @@ -83,6 +113,7 @@ await container.withEnvironment("MY_EXPR", expr); // withEnvironment — with ParameterResource await container.withEnvironment("MY_PARAM", configParam); +await container.withEnvironment("MY_GENERATED_PARAM", generatedParam); // withEnvironment — with connection string resource await container.withEnvironment("MY_CONN", envConnectionString); @@ -90,8 +121,8 @@ await container.withEnvironment("MY_CONN", envConnectionString); // withConnectionProperty — with ReferenceExpression await builtConnectionString.withConnectionProperty("Endpoint", expr); -// withConnectionPropertyValue — with string -await builtConnectionString.withConnectionPropertyValue("Protocol", "https"); +// withConnectionProperty — with string +await builtConnectionString.withConnectionProperty("Protocol", "https"); // excludeFromManifest await container.excludeFromManifest(); @@ -117,6 +148,10 @@ await container.withoutHttpsCertificate(); // withChildRelationship await container.withChildRelationship(exe); +// withRelationship +await container.withRelationship(taggedContainer, "peer"); +await project.withReference(cache); + // withIconName await container.withIconName("Database", { iconVariant: IconVariant.Filled }); @@ -393,6 +428,7 @@ await container.withArgs(["--verbose"]); // withParentRelationship await container.withParentRelationship(exe); +await projectWithoutLaunchProfile.withParentRelationship(project); // withExplicitStart await container.withExplicitStart(); diff --git a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.aspire/settings.json b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json similarity index 64% rename from playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.aspire/settings.json rename to playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json index 3ddcccce18d..8c6102c5d73 100644 --- a/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/.aspire/settings.json +++ b/playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/aspire.config.json @@ -1,6 +1,8 @@ { - "appHostPath": "../apphost.ts", - "language": "typescript/nodejs", + "appHost": { + "path": "apphost.ts", + "language": "typescript/nodejs" + }, "packages": { "Aspire.Hosting": "", "Aspire.Hosting.Testing": "", diff --git a/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIDeploymentResource.cs b/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIDeploymentResource.cs index aee25dc9161..1b8ad3b3405 100644 --- a/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIDeploymentResource.cs +++ b/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIDeploymentResource.cs @@ -97,15 +97,11 @@ public string SkuName /// /// Gets the parent Azure OpenAI resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public AzureOpenAIResource Parent { get; } /// /// Gets the connection string expression for the Azure OpenAI Deployment resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public ReferenceExpression ConnectionStringExpression => Parent.GetConnectionString(DeploymentName); IEnumerable> IResourceWithConnectionString.GetConnectionProperties() diff --git a/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIResource.cs b/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIResource.cs index 733c6feda16..1f82c3534eb 100644 --- a/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIResource.cs +++ b/src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIResource.cs @@ -11,6 +11,7 @@ namespace Aspire.Hosting.ApplicationModel; /// /// The name of the resource. /// Configures the underlying Azure resource using Azure.Provisioning. +[AspireExport] public class AzureOpenAIResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure), IResourceWithConnectionString diff --git a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubResource.cs b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubResource.cs index 7e1eafa2675..36a213652c9 100644 --- a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubResource.cs +++ b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubResource.cs @@ -36,15 +36,11 @@ public class AzureEventHubResource(string name, string hubName, AzureEventHubsRe /// /// Gets the parent Azure Event Hubs resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public AzureEventHubsResource Parent { get; } = parent ?? throw new ArgumentNullException(nameof(parent)); /// /// Gets the connection string expression for the Azure Event Hub. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public ReferenceExpression ConnectionStringExpression => Parent.GetConnectionString(HubName); /// diff --git a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs index 717f7818fbc..6f3d50aac09 100644 --- a/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs +++ b/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs @@ -14,6 +14,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Event Hubs resource. +[AspireExport] public class AzureEventHubsResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure), IResourceWithConnectionString, IResourceWithEndpoints, IResourceWithAzureFunctionsConfig, IAzurePrivateEndpointTarget { diff --git a/src/Aspire.Hosting.Azure.Kusto/AzureKustoClusterResource.cs b/src/Aspire.Hosting.Azure.Kusto/AzureKustoClusterResource.cs index dfb2276806d..01c0cb7777b 100644 --- a/src/Aspire.Hosting.Azure.Kusto/AzureKustoClusterResource.cs +++ b/src/Aspire.Hosting.Azure.Kusto/AzureKustoClusterResource.cs @@ -36,15 +36,11 @@ public AzureKustoClusterResource(string name, Action /// Gets the "name" output reference for the resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public BicepOutputReference NameOutputReference => new("name", this); /// /// Gets the cluster URI output reference for the Azure Kusto cluster. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public BicepOutputReference ClusterUri => new("clusterUri", this); /// diff --git a/src/Aspire.Hosting.Azure.Kusto/AzureKustoHealthCheckBuilderExtensions.cs b/src/Aspire.Hosting.Azure.Kusto/AzureKustoHealthCheckBuilderExtensions.cs index 5c8c3823255..e0f8f5dc693 100644 --- a/src/Aspire.Hosting.Azure.Kusto/AzureKustoHealthCheckBuilderExtensions.cs +++ b/src/Aspire.Hosting.Azure.Kusto/AzureKustoHealthCheckBuilderExtensions.cs @@ -18,7 +18,7 @@ internal static class AzureKustoHealthCheckBuilderExtensions /// The Kusto connection string builder. /// The updated health check builder. /// This method is not available in polyglot app hosts. - [AspireExportIgnore(Reason = "IHealthChecksBuilder extensions and IServiceProvider callbacks are not ATS-compatible.")] + [AspireExportIgnore(Reason = "IHealthChecksBuilder extensions and callbacks returning KustoConnectionStringBuilder are not ATS-compatible.")] public static IHealthChecksBuilder AddAzureKustoHealthCheck(this IHealthChecksBuilder builder, string name, bool isCluster, Func connectionStringFactory) { ArgumentNullException.ThrowIfNull(builder); diff --git a/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs b/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs index a7c3150147b..c50a126d402 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs @@ -17,6 +17,7 @@ namespace Aspire.Hosting.Azure; /// /// Use to configure specific properties. /// +[AspireExport] public class AzureSubnetResource : Resource, IResourceWithParent { // Backing field holds either string or ParameterResource diff --git a/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs b/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs index 62ebc2f8461..2f066d060b4 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs @@ -12,6 +12,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Virtual Network resource. +[AspireExport] public class AzureVirtualNetworkResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { diff --git a/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs b/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs index 3d7d92d3fc1..555162aebd5 100644 --- a/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs +++ b/src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs @@ -46,15 +46,11 @@ public class AzureManagedRedisResource(string name, Action /// Gets the "name" output reference for the resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public BicepOutputReference NameOutputReference => new("name", this); /// /// Gets the "id" output reference for the resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public BicepOutputReference Id => new("id", this); /// diff --git a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusQueueResource.cs b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusQueueResource.cs index 0e210a93238..03adcf4c028 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusQueueResource.cs +++ b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusQueueResource.cs @@ -37,15 +37,11 @@ public string QueueName /// /// Gets the parent Azure Service Bus resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public AzureServiceBusResource Parent { get; } = parent ?? throw new ArgumentNullException(nameof(parent)); /// /// Gets the connection string expression for the Azure Service Bus Queue. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public ReferenceExpression ConnectionStringExpression => Parent.GetConnectionString(QueueName, null); /// diff --git a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs index b7549ecca2c..ab274bb20e9 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs +++ b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs @@ -14,6 +14,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Service Bus resource. +[AspireExport] public class AzureServiceBusResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure), IResourceWithConnectionString, IResourceWithAzureFunctionsConfig, IResourceWithEndpoints, IAzurePrivateEndpointTarget { diff --git a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusSubscriptionResource.cs b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusSubscriptionResource.cs index 3027ddd8eae..85b44058e59 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusSubscriptionResource.cs +++ b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusSubscriptionResource.cs @@ -37,15 +37,11 @@ public string SubscriptionName /// /// Gets the parent Azure Service Bus Topic resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public AzureServiceBusTopicResource Parent { get; } = parent ?? throw new ArgumentNullException(nameof(parent)); /// /// Gets the connection string expression for the Azure Service Bus Subscription. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public ReferenceExpression ConnectionStringExpression => Parent.Parent.GetConnectionString(Parent.TopicName, SubscriptionName); /// diff --git a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusTopicResource.cs b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusTopicResource.cs index 68386802d43..6a5148f6c71 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusTopicResource.cs +++ b/src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusTopicResource.cs @@ -37,15 +37,11 @@ public string TopicName /// /// Gets the parent Azure Service Bus resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public AzureServiceBusResource Parent { get; } = parent ?? throw new ArgumentNullException(nameof(parent)); /// /// Gets the connection string expression for the Azure Service Bus Topic. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public ReferenceExpression ConnectionStringExpression => Parent.GetConnectionString(TopicName, null); /// diff --git a/src/Aspire.Hosting.Azure.Sql/AzureSqlExtensions.cs b/src/Aspire.Hosting.Azure.Sql/AzureSqlExtensions.cs index 17c4c05dc43..704ce2e324b 100644 --- a/src/Aspire.Hosting.Azure.Sql/AzureSqlExtensions.cs +++ b/src/Aspire.Hosting.Azure.Sql/AzureSqlExtensions.cs @@ -373,9 +373,6 @@ private static SqlServer CreateSqlServerResourceOnly(AzureResourceInfrastructure /// Ensure the subnet has outbound network security rules allowing access to Azure Active Directory (port 443) /// and SQL (port 443) service tags. /// - /// - /// This method is not available in polyglot app hosts. - /// /// /// /// Provide a custom ACI subnet for the deployment script: @@ -389,7 +386,7 @@ private static SqlServer CreateSqlServerResourceOnly(AzureResourceInfrastructure /// peSubnet.AddPrivateEndpoint(sql); /// /// - [AspireExportIgnore(Reason = "Azure subnet resources are not currently available to polyglot app hosts.")] + [AspireExport("withAdminDeploymentScriptSubnet", Description = "Configures the Azure SQL server to use a specific subnet for deployment scripts")] [Experimental("ASPIREAZURE003", UrlFormat = "https://aka.ms/dotnet/aspire/diagnostics#{0}")] public static IResourceBuilder WithAdminDeploymentScriptSubnet( this IResourceBuilder builder, diff --git a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs index 5c01b66d442..8a99d214736 100644 --- a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs +++ b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs @@ -58,22 +58,16 @@ public AzureSqlServerResource(SqlServerServerResource innerResource, Action /// Gets the fully qualified domain name (FQDN) output reference from the bicep template for the Azure SQL Server resource. /// - /// This property is not available in polyglot app hosts. Use instead. - [AspireExportIgnore] public BicepOutputReference FullyQualifiedDomainName => new("sqlServerFqdn", this); /// /// Gets the "name" output reference for the resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public BicepOutputReference NameOutputReference => new("name", this); /// /// Gets the "id" output reference for the resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public BicepOutputReference Id => new("id", this); private BicepOutputReference AdminName => new("sqlServerAdminName", this); @@ -168,8 +162,6 @@ public ReferenceExpression ConnectionStringExpression /// /// A dictionary where the key is the resource name and the value is the Azure SQL database resource. /// - /// This property is not available in polyglot app hosts. Use instead. - [AspireExportIgnore] public IReadOnlyDictionary AzureSqlDatabases => _databases; /// diff --git a/src/Aspire.Hosting.Azure/ExistingAzureResourceExtensions.cs b/src/Aspire.Hosting.Azure/ExistingAzureResourceExtensions.cs index 4d6a4f98389..1350061e865 100644 --- a/src/Aspire.Hosting.Azure/ExistingAzureResourceExtensions.cs +++ b/src/Aspire.Hosting.Azure/ExistingAzureResourceExtensions.cs @@ -45,18 +45,13 @@ internal static bool IsExistingForPolyglot(this IAzureResource resource) /// The name of the existing resource. /// The name of the existing resource group, or to use the current resource group. /// The resource builder with the existing resource annotation added. - [AspireExport("runAsExistingFromParameters", Description = "Marks an Azure resource as existing in run mode by using parameter resources")] + [AspireExportIgnore(Reason = "Use the polyglot runAsExisting overload that accepts string or ParameterResource values instead.")] public static IResourceBuilder RunAsExisting(this IResourceBuilder builder, IResourceBuilder nameParameter, IResourceBuilder? resourceGroupParameter) where T : IAzureResource { ArgumentNullException.ThrowIfNull(builder); - if (!builder.ApplicationBuilder.ExecutionContext.IsPublishMode) - { - builder.WithAnnotation(new ExistingAzureResourceAnnotation(nameParameter.Resource, resourceGroupParameter?.Resource)); - } - - return builder; + return RunAsExistingCore(builder, nameParameter.Resource, resourceGroupParameter?.Resource); } /// @@ -67,18 +62,34 @@ public static IResourceBuilder RunAsExisting(this IResourceBuilder buil /// The name of the existing resource. /// The name of the existing resource group, or to use the current resource group. /// The resource builder with the existing resource annotation added. - [AspireExport("runAsExisting", Description = "Marks an Azure resource as existing in run mode")] + [AspireExportIgnore(Reason = "Use the polyglot runAsExisting overload that accepts string or ParameterResource values instead.")] public static IResourceBuilder RunAsExisting(this IResourceBuilder builder, string name, string? resourceGroup) where T : IAzureResource { ArgumentNullException.ThrowIfNull(builder); - if (!builder.ApplicationBuilder.ExecutionContext.IsPublishMode) - { - builder.WithAnnotation(new ExistingAzureResourceAnnotation(name, resourceGroup)); - } + return RunAsExistingCore(builder, name, resourceGroup); + } - return builder; + /// + /// Marks the resource as an existing resource when the application is running. + /// + /// The type of the resource. + /// The resource builder. + /// The name of the existing resource as a string or parameter resource. + /// The name of the existing resource group as a string or parameter resource. + /// The resource builder with the existing resource annotation added. + [AspireExport("runAsExisting", Description = "Marks an Azure resource as existing in run mode")] + internal static IResourceBuilder RunAsExistingForPolyglot( + this IResourceBuilder builder, + [AspireUnion(typeof(string), typeof(ParameterResource))] object name, + [AspireUnion(typeof(string), typeof(ParameterResource))] object? resourceGroup = null) + where T : IAzureResource + { + ValidateExistingResourceArgument(name, nameof(name)); + ValidateExistingResourceArgument(resourceGroup, nameof(resourceGroup), allowNull: true); + + return RunAsExistingCore(builder, name, resourceGroup); } /// @@ -89,18 +100,13 @@ public static IResourceBuilder RunAsExisting(this IResourceBuilder buil /// The name of the existing resource. /// The name of the existing resource group, or to use the current resource group. /// The resource builder with the existing resource annotation added. - [AspireExport("publishAsExistingFromParameters", Description = "Marks an Azure resource as existing in publish mode by using parameter resources")] + [AspireExportIgnore(Reason = "Use the polyglot publishAsExisting overload that accepts string or ParameterResource values instead.")] public static IResourceBuilder PublishAsExisting(this IResourceBuilder builder, IResourceBuilder nameParameter, IResourceBuilder? resourceGroupParameter) where T : IAzureResource { ArgumentNullException.ThrowIfNull(builder); - if (builder.ApplicationBuilder.ExecutionContext.IsPublishMode) - { - builder.WithAnnotation(new ExistingAzureResourceAnnotation(nameParameter.Resource, resourceGroupParameter?.Resource)); - } - - return builder; + return PublishAsExistingCore(builder, nameParameter.Resource, resourceGroupParameter?.Resource); } /// @@ -111,18 +117,34 @@ public static IResourceBuilder PublishAsExisting(this IResourceBuilder /// The name of the existing resource. /// The name of the existing resource group, or to use the current resource group. /// The resource builder with the existing resource annotation added. - [AspireExport("publishAsExisting", Description = "Marks an Azure resource as existing in publish mode")] + [AspireExportIgnore(Reason = "Use the polyglot publishAsExisting overload that accepts string or ParameterResource values instead.")] public static IResourceBuilder PublishAsExisting(this IResourceBuilder builder, string name, string? resourceGroup) where T : IAzureResource { ArgumentNullException.ThrowIfNull(builder); - if (builder.ApplicationBuilder.ExecutionContext.IsPublishMode) - { - builder.WithAnnotation(new ExistingAzureResourceAnnotation(name, resourceGroup)); - } + return PublishAsExistingCore(builder, name, resourceGroup); + } - return builder; + /// + /// Marks the resource as an existing resource when the application is deployed. + /// + /// The type of the resource. + /// The resource builder. + /// The name of the existing resource as a string or parameter resource. + /// The name of the existing resource group as a string or parameter resource. + /// The resource builder with the existing resource annotation added. + [AspireExport("publishAsExisting", Description = "Marks an Azure resource as existing in publish mode")] + internal static IResourceBuilder PublishAsExistingForPolyglot( + this IResourceBuilder builder, + [AspireUnion(typeof(string), typeof(ParameterResource))] object name, + [AspireUnion(typeof(string), typeof(ParameterResource))] object? resourceGroup = null) + where T : IAzureResource + { + ValidateExistingResourceArgument(name, nameof(name)); + ValidateExistingResourceArgument(resourceGroup, nameof(resourceGroup), allowNull: true); + + return PublishAsExistingCore(builder, name, resourceGroup); } /// @@ -133,14 +155,87 @@ public static IResourceBuilder PublishAsExisting(this IResourceBuilder /// The name of the existing resource. /// The name of the existing resource group, or to use the current resource group. /// The resource builder with the existing resource annotation added. - [AspireExport("asExistingFromParameters", MethodName = "asExisting", Description = "Marks an Azure resource as existing in both run and publish modes by using parameter resources")] + [AspireExportIgnore(Reason = "Use the polyglot asExisting overload that accepts string or ParameterResource values instead.")] public static IResourceBuilder AsExisting(this IResourceBuilder builder, IResourceBuilder nameParameter, IResourceBuilder? resourceGroupParameter) where T : IAzureResource { ArgumentNullException.ThrowIfNull(builder); - builder.WithAnnotation(new ExistingAzureResourceAnnotation(nameParameter.Resource, resourceGroupParameter?.Resource)); + return AsExistingCore(builder, nameParameter.Resource, resourceGroupParameter?.Resource); + } + + /// + /// Marks the resource as an existing resource in both run and publish modes. + /// + /// The type of the resource. + /// The resource builder. + /// The name of the existing resource as a string or parameter resource. + /// The name of the existing resource group as a string or parameter resource. + /// The resource builder with the existing resource annotation added. + [AspireExport("asExisting", Description = "Marks an Azure resource as existing in both run and publish modes")] + internal static IResourceBuilder AsExistingForPolyglot( + this IResourceBuilder builder, + [AspireUnion(typeof(string), typeof(ParameterResource))] object name, + [AspireUnion(typeof(string), typeof(ParameterResource))] object? resourceGroup = null) + where T : IAzureResource + { + ValidateExistingResourceArgument(name, nameof(name)); + ValidateExistingResourceArgument(resourceGroup, nameof(resourceGroup), allowNull: true); + + return AsExistingCore(builder, name, resourceGroup); + } + + private static IResourceBuilder RunAsExistingCore(IResourceBuilder builder, object name, object? resourceGroup) + where T : IAzureResource + { + ArgumentNullException.ThrowIfNull(builder); + + if (!builder.ApplicationBuilder.ExecutionContext.IsPublishMode) + { + builder.WithAnnotation(new ExistingAzureResourceAnnotation(name, resourceGroup)); + } return builder; } + + private static IResourceBuilder PublishAsExistingCore(IResourceBuilder builder, object name, object? resourceGroup) + where T : IAzureResource + { + ArgumentNullException.ThrowIfNull(builder); + + if (builder.ApplicationBuilder.ExecutionContext.IsPublishMode) + { + builder.WithAnnotation(new ExistingAzureResourceAnnotation(name, resourceGroup)); + } + + return builder; + } + + private static IResourceBuilder AsExistingCore(IResourceBuilder builder, object name, object? resourceGroup) + where T : IAzureResource + { + ArgumentNullException.ThrowIfNull(builder); + + builder.WithAnnotation(new ExistingAzureResourceAnnotation(name, resourceGroup)); + + return builder; + } + + private static void ValidateExistingResourceArgument(object? value, string paramName, bool allowNull = false) + { + if (value is null) + { + if (allowNull) + { + return; + } + + throw new ArgumentNullException(paramName); + } + + if (value is not string && value is not ParameterResource) + { + throw new ArgumentException("Value must be a string or ParameterResource.", paramName); + } + } } diff --git a/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs index 29ea4501cc6..b220f2c38c4 100644 --- a/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs @@ -308,7 +308,7 @@ private void GenerateCapabilityMethod(string structName, AtsCapabilityInfo capab { paramList.Append(", "); } - var paramName = ToCamelCase(parameter.Name); + var paramName = GetLocalIdentifier(parameter.Name); var paramType = parameter.IsCallback ? "func(...any) any" : IsCancellationToken(parameter) @@ -331,7 +331,7 @@ private void GenerateCapabilityMethod(string structName, AtsCapabilityInfo capab foreach (var parameter in parameters) { - var paramName = ToCamelCase(parameter.Name); + var paramName = GetLocalIdentifier(parameter.Name); if (parameter.IsCallback) { WriteLine($"\tif {paramName} != nil {{"); @@ -827,6 +827,8 @@ private static string SanitizeIdentifier(string name) return s_goKeywords.Contains(sanitized) ? sanitized + "_" : sanitized; } + private static string GetLocalIdentifier(string name) => SanitizeIdentifier(ToCamelCase(name)); + /// /// Converts a name to PascalCase for Go exported identifiers. /// diff --git a/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs b/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs index 33ea6c05f6e..0c2d94fad54 100644 --- a/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs +++ b/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs @@ -989,7 +989,7 @@ private static string ToSnakeCase(string name) return name; } - return JsonNamingPolicy.SnakeCaseLower.ConvertName(name); + return SanitizeIdentifier(JsonNamingPolicy.SnakeCaseLower.ConvertName(name)); } private void WriteLine(string value = "") diff --git a/src/Aspire.Hosting.Foundry/FoundryDeploymentResource.cs b/src/Aspire.Hosting.Foundry/FoundryDeploymentResource.cs index f90fcd9d91b..54aa35072f8 100644 --- a/src/Aspire.Hosting.Foundry/FoundryDeploymentResource.cs +++ b/src/Aspire.Hosting.Foundry/FoundryDeploymentResource.cs @@ -93,8 +93,6 @@ public FoundryDeploymentResource(string name, string modelName, string modelVers /// /// Gets the parent Microsoft Foundry resource. /// - /// This property is not available in polyglot app hosts. - [AspireExportIgnore] public FoundryResource Parent { get; set; } /// diff --git a/src/Aspire.Hosting.Foundry/FoundryResource.cs b/src/Aspire.Hosting.Foundry/FoundryResource.cs index a3d85f5e5b6..f351cfc355b 100644 --- a/src/Aspire.Hosting.Foundry/FoundryResource.cs +++ b/src/Aspire.Hosting.Foundry/FoundryResource.cs @@ -13,6 +13,7 @@ namespace Aspire.Hosting.Foundry; /// /// The name of the resource. /// Configures the underlying Azure resource using Azure.Provisioning. +[AspireExport] public class FoundryResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure), IResourceWithEndpoints, IResourceWithConnectionString { diff --git a/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs b/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs index 7a4ad61dcae..ccab0e77435 100644 --- a/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs +++ b/src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs @@ -173,11 +173,128 @@ public static CapabilityHostBuilder AddCapabilityHost( ArgumentNullException.ThrowIfNull(builder); ArgumentException.ThrowIfNullOrEmpty(name); - var config = new CapabilityHostConfiguration(name); - builder.Resource.CapabilityHostConfiguration = config; + var config = CreateCapabilityHostConfiguration(builder, name); return new CapabilityHostBuilder(builder, config); } + /// + /// Adds a capability host to the Microsoft Foundry project. + /// + /// The resource builder for the Microsoft Foundry project. + /// The name of the capability host. + /// A reference to the project builder for chaining capability host configuration. + [AspireExport("addCapabilityHostProject", MethodName = "addCapabilityHost", Description = "Adds a capability host to a Microsoft Foundry project.")] + internal static IResourceBuilder AddCapabilityHostExport( + this IResourceBuilder builder, + [ResourceName] string name) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentException.ThrowIfNullOrEmpty(name); + + CreateCapabilityHostConfiguration(builder, name); + return builder; + } + + /// + /// Configures the Cosmos DB resource for the capability host on a Microsoft Foundry project. + /// + /// The resource builder for the Microsoft Foundry project. + /// The Cosmos DB resource builder. + /// A reference to the project builder for chaining capability host configuration. + [AspireExportIgnore(Reason = "Use the polyglot withCapabilityHost overload instead.")] + internal static IResourceBuilder WithCapabilityHostCosmosDB( + this IResourceBuilder builder, + IResourceBuilder cosmosDb) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(cosmosDb); + + GetCapabilityHostConfiguration(builder).CosmosDB = cosmosDb.Resource; + return builder; + } + + /// + /// Configures the Storage resource for the capability host on a Microsoft Foundry project. + /// + /// The resource builder for the Microsoft Foundry project. + /// The Storage resource builder. + /// A reference to the project builder for chaining capability host configuration. + [AspireExportIgnore(Reason = "Use the polyglot withCapabilityHost overload instead.")] + internal static IResourceBuilder WithCapabilityHostStorage( + this IResourceBuilder builder, + IResourceBuilder storage) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(storage); + + GetCapabilityHostConfiguration(builder).Storage = storage.Resource; + return builder; + } + + /// + /// Configures the Azure Search resource for the capability host on a Microsoft Foundry project. + /// + /// The resource builder for the Microsoft Foundry project. + /// The Azure Search resource builder. + /// A reference to the project builder for chaining capability host configuration. + [AspireExportIgnore(Reason = "Use the polyglot withCapabilityHost overload instead.")] + internal static IResourceBuilder WithCapabilityHostSearch( + this IResourceBuilder builder, + IResourceBuilder search) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(search); + + GetCapabilityHostConfiguration(builder).Search = search.Resource; + return builder; + } + + /// + /// Configures the Microsoft Foundry resource used for Azure OpenAI model calls by the capability host. + /// + /// The resource builder for the Microsoft Foundry project. + /// The Microsoft Foundry resource builder. + /// A reference to the project builder for chaining capability host configuration. + [AspireExportIgnore(Reason = "Use the polyglot withCapabilityHost overload instead.")] + internal static IResourceBuilder WithCapabilityHostAzureOpenAI( + this IResourceBuilder builder, + IResourceBuilder openAI) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(openAI); + + GetCapabilityHostConfiguration(builder).AzureOpenAI = openAI.Resource; + return builder; + } + + /// + /// Associates a supported resource with a capability host on a Microsoft Foundry project. + /// + /// The resource builder for the Microsoft Foundry project. + /// The supported capability host resource. + /// A reference to the project builder for chaining capability host configuration. + [AspireExport("withCapabilityHost", Description = "Associates a supported resource with a capability host on a Microsoft Foundry project.")] + internal static IResourceBuilder WithCapabilityHost( + this IResourceBuilder builder, + [AspireUnion( + typeof(IResourceBuilder), + typeof(IResourceBuilder), + typeof(IResourceBuilder), + typeof(IResourceBuilder))] object resource) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(resource); + + return resource switch + { + IResourceBuilder cosmosDb => builder.WithCapabilityHostCosmosDB(cosmosDb), + IResourceBuilder storage => builder.WithCapabilityHostStorage(storage), + IResourceBuilder search => builder.WithCapabilityHostSearch(search), + IResourceBuilder openAI => builder.WithCapabilityHostAzureOpenAI(openAI), + _ => throw new ArgumentException("Resource must be a supported capability host resource.", nameof(resource)) + }; + } + /// /// Adds a model deployment to the parent Microsoft Foundry resource of the Microsoft Foundry project. /// @@ -605,4 +722,17 @@ static void configureInfrastructure(AzureResourceInfrastructure infrastructure) builder.AddResource(resource); return resource; } + + private static CapabilityHostConfiguration CreateCapabilityHostConfiguration( + IResourceBuilder builder, + string name) + { + var config = new CapabilityHostConfiguration(name); + builder.Resource.CapabilityHostConfiguration = config; + return config; + } + + private static CapabilityHostConfiguration GetCapabilityHostConfiguration(IResourceBuilder builder) + => builder.Resource.CapabilityHostConfiguration + ?? throw new InvalidOperationException($"Microsoft Foundry project resource '{builder.Resource.Name}' does not have a capability host configured. Call addCapabilityHost first."); } diff --git a/src/Aspire.Hosting/ApplicationModel/ParameterDefault.cs b/src/Aspire.Hosting/ApplicationModel/ParameterDefault.cs index 663d65ecaa7..e3c4ebea4fb 100644 --- a/src/Aspire.Hosting/ApplicationModel/ParameterDefault.cs +++ b/src/Aspire.Hosting/ApplicationModel/ParameterDefault.cs @@ -76,6 +76,7 @@ public abstract class ParameterDefault /// log base 2 [67^x * 23^a * 23^b * 10^c * 11^d * (a + b + c + d)! / (a! * b! * c! * d!)] /// /// +[AspireDto] public sealed class GenerateParameterDefault : ParameterDefault { /// diff --git a/src/Aspire.Hosting/Ats/AddContainerOptions.cs b/src/Aspire.Hosting/Ats/AddContainerOptions.cs new file mode 100644 index 00000000000..7ad4bf1b76e --- /dev/null +++ b/src/Aspire.Hosting/Ats/AddContainerOptions.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Aspire.Hosting.Ats; + +/// +/// Options for configuring a container image in polyglot apphosts. +/// +[AspireDto] +internal sealed class AddContainerOptions +{ + /// + /// The container image name. + /// + public required string Image { get; init; } + + /// + /// The container image tag. + /// + public string? Tag { get; init; } +} diff --git a/src/Aspire.Hosting/Ats/ReferenceEnvironmentInjectionOptions.cs b/src/Aspire.Hosting/Ats/ReferenceEnvironmentInjectionOptions.cs new file mode 100644 index 00000000000..9c4cba7f84b --- /dev/null +++ b/src/Aspire.Hosting/Ats/ReferenceEnvironmentInjectionOptions.cs @@ -0,0 +1,64 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Hosting.ApplicationModel; + +namespace Aspire.Hosting.Ats; + +/// +/// Options that control which reference information is injected into environment variables. +/// +[AspireDto] +internal sealed class ReferenceEnvironmentInjectionOptions +{ + /// + /// Injects the connection string environment variable. + /// + public bool ConnectionString { get; set; } + + /// + /// Injects individual connection property environment variables. + /// + public bool ConnectionProperties { get; set; } + + /// + /// Injects service discovery environment variables. + /// + public bool ServiceDiscovery { get; set; } + + /// + /// Injects endpoint environment variables. + /// + public bool Endpoints { get; set; } + + /// + /// Converts the DTO into the corresponding flags enum. + /// + /// The selected injection flags. + public ReferenceEnvironmentInjectionFlags ToFlags() + { + var flags = ReferenceEnvironmentInjectionFlags.None; + + if (ConnectionString) + { + flags |= ReferenceEnvironmentInjectionFlags.ConnectionString; + } + + if (ConnectionProperties) + { + flags |= ReferenceEnvironmentInjectionFlags.ConnectionProperties; + } + + if (ServiceDiscovery) + { + flags |= ReferenceEnvironmentInjectionFlags.ServiceDiscovery; + } + + if (Endpoints) + { + flags |= ReferenceEnvironmentInjectionFlags.Endpoints; + } + + return flags; + } +} diff --git a/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs b/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs index d97965c4419..f2494cd285a 100644 --- a/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs @@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text; +using Aspire.Hosting.Ats; using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.ApplicationModel.Docker; using Aspire.Hosting.Pipelines; @@ -90,7 +91,7 @@ await containerImageBuilder.BuildImageAsync( /// The name of the resource. /// The container image name. The tag is assumed to be "latest". /// The for chaining. - [AspireExport("addContainer", Description = "Adds a container resource")] + [AspireExportIgnore(Reason = "Use the polyglot addContainer overload that accepts a string or AddContainerOptions value.")] public static IResourceBuilder AddContainer(this IDistributedApplicationBuilder builder, [ResourceName] string name, string image) { ArgumentNullException.ThrowIfNull(builder); @@ -110,14 +111,55 @@ public static IResourceBuilder AddContainer(this IDistributed /// The container image name. /// The container image tag. /// The for chaining. - /// This method is not available in polyglot app hosts. Use with instead. - [AspireExportIgnore(Reason = "Use AddContainer with WithImageTag instead for a cleaner API.")] + [AspireExportIgnore(Reason = "Use the polyglot addContainer overload that accepts a string or AddContainerOptions value.")] public static IResourceBuilder AddContainer(this IDistributedApplicationBuilder builder, [ResourceName] string name, string image, string tag) { return AddContainer(builder, name, image) .WithImageTag(tag); } + /// + /// Adds a container resource to the application. + /// + /// The . + /// The name of the resource. + /// The image name or image options for the container. + /// The for chaining. + [AspireExport("addContainer", Description = "Adds a container resource")] + internal static IResourceBuilder AddContainerForPolyglot( + this IDistributedApplicationBuilder builder, + [ResourceName] string name, + [AspireUnion(typeof(string), typeof(AddContainerOptions))] object image) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentException.ThrowIfNullOrEmpty(name); + ArgumentNullException.ThrowIfNull(image); + + return image switch + { + string imageName => AddContainer(builder, name, imageName), + AddContainerOptions options => AddContainer(builder, name, options), + _ => throw new ArgumentException("Image must be a string or AddContainerOptions.", nameof(image)) + }; + } + + private static IResourceBuilder AddContainer( + IDistributedApplicationBuilder builder, + string name, + AddContainerOptions options) + { + ArgumentNullException.ThrowIfNull(options); + ArgumentException.ThrowIfNullOrEmpty(options.Image); + + if (options.Tag is { } tag) + { + ArgumentException.ThrowIfNullOrEmpty(tag); + return AddContainer(builder, name, options.Image, tag); + } + + return AddContainer(builder, name, options.Image); + } + /// /// Adds a volume to a container resource. /// @@ -1039,7 +1081,7 @@ public static IResourceBuilder WithContainerName(this IResourceBuilder /// /// /// - /// This method is not available in polyglot app hosts. Use the ParameterResource overload instead. + /// This method is not available in polyglot app hosts. Use the ATS dispatcher overload instead. [AspireExportIgnore(Reason = "Uses object parameter which is not ATS-compatible.")] public static IResourceBuilder WithBuildArg(this IResourceBuilder builder, string name, object? value) where T : ContainerResource { @@ -1091,7 +1133,7 @@ public static IResourceBuilder WithBuildArg(this IResourceBuilder build /// /// /// - [AspireExport("withParameterBuildArg", MethodName = "withBuildArg", Description = "Adds a build argument from a parameter resource")] + [AspireExportIgnore(Reason = "Polyglot app hosts use the union-based withBuildArg dispatcher export.")] public static IResourceBuilder WithBuildArg(this IResourceBuilder builder, string name, IResourceBuilder value) where T : ContainerResource { ArgumentNullException.ThrowIfNull(builder); @@ -1106,6 +1148,34 @@ public static IResourceBuilder WithBuildArg(this IResourceBuilder build return builder.WithBuildArg(name, value.Resource); } + /// + /// Adds a build argument when the container is built from a Dockerfile. + /// + /// The type of container resource. + /// The resource builder for the container resource. + /// The name of the build argument. + /// The build argument value, either a string or a parameter resource. + /// The . + [AspireExport("withBuildArg", Description = "Adds a build argument from a string value or parameter resource")] + internal static IResourceBuilder WithBuildArgExport( + this IResourceBuilder builder, + string name, + [AspireUnion(typeof(string), typeof(IResourceBuilder))] object value) where T : ContainerResource + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentException.ThrowIfNullOrEmpty(name); + ArgumentNullException.ThrowIfNull(value); + + return value switch + { + string stringValue => builder.WithBuildArg(name, (object?)stringValue), + IResourceBuilder parameter => builder.WithBuildArg(name, parameter), + _ => throw new ArgumentException( + $"Unsupported build argument type '{value.GetType().Name}'. Expected string or IResourceBuilder.", + nameof(value)) + }; + } + /// /// Adds a secret build argument when the container is built from a Dockerfile. /// @@ -1168,7 +1238,7 @@ public static IResourceBuilder WithBuildSecret(this IResourceBuilder bu /// List of default certificate bundle paths in the container that will be replaced in or modes. If not specified, defaults to /etc/ssl/certs/ca-certificates.crt for Linux containers. /// List of default certificate directory paths in the container that may be appended to the custom certificates directory in mode. If not specified, defaults to /usr/local/share/ca-certificates/ for Linux containers. /// The updated resource builder. - /// This method is not available in polyglot app hosts. + /// This method is not available in polyglot app hosts. Use the ATS wrapper overload instead. [AspireExportIgnore(Reason = "Uses List which is not ATS-compatible (only T[] is supported, not List).")] public static IResourceBuilder WithContainerCertificatePaths(this IResourceBuilder builder, string? customCertificatesDestination = null, List? defaultCertificateBundlePaths = null, List? defaultCertificateDirectoryPaths = null) where TResource : ContainerResource @@ -1183,6 +1253,31 @@ public static IResourceBuilder WithContainerCertificatePaths + /// Adds container certificate path overrides used for certificate trust at run time. + /// + /// The type of the resource. + /// The resource builder. + /// The destination path in the container where custom certificates will be copied. + /// Default certificate bundle paths in the container that will be replaced. + /// Default certificate directory paths in the container that may be appended. + /// The updated resource builder. + [AspireExport("withContainerCertificatePaths", Description = "Overrides container certificate bundle and directory paths used for trust configuration")] + internal static IResourceBuilder WithContainerCertificatePathsExport( + this IResourceBuilder builder, + string? customCertificatesDestination = null, + string[]? defaultCertificateBundlePaths = null, + string[]? defaultCertificateDirectoryPaths = null) + where TResource : ContainerResource + { + ArgumentNullException.ThrowIfNull(builder); + + return builder.WithContainerCertificatePaths( + customCertificatesDestination, + defaultCertificateBundlePaths?.ToList(), + defaultCertificateDirectoryPaths?.ToList()); + } + /// /// Creates or updates files and/or folders at the destination path in the container. /// diff --git a/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs b/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs index 7242b6aabac..ceb4e37ac73 100644 --- a/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs @@ -160,6 +160,16 @@ public static IResourceBuilder AddParameter(this IDistributed }); } + [AspireExport("addParameterWithGeneratedValue", Description = "Adds a parameter with a generated default value")] + internal static IResourceBuilder AddParameterWithGeneratedValueForPolyglot(this IDistributedApplicationBuilder builder, [ResourceName] string name, GenerateParameterDefault value, bool secret = false, bool persist = false) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(name); + ArgumentNullException.ThrowIfNull(value); + + return builder.AddParameter(name, (ParameterDefault)value, secret, persist); + } + /// /// Sets the description of the parameter resource. /// diff --git a/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs b/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs index a8d0ee6c746..17786cd96b1 100644 --- a/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs @@ -97,9 +97,12 @@ public static class ProjectResourceBuilderExtensions /// builder.Build().Run(); /// /// - /// This method is not available in polyglot app hosts. Use the overload with projectPath and launchProfileName instead. + /// + /// This overload is also exported to polyglot app hosts as addProjectWithoutLaunchProfile for the common case + /// where no launch profile is needed. + /// /// - [AspireExportIgnore(Reason = "Use the overload with launchProfileName for full control.")] + [AspireExport("addProjectWithoutLaunchProfile", Description = "Adds a .NET project resource without a launch profile")] public static IResourceBuilder AddProject(this IDistributedApplicationBuilder builder, [ResourceName] string name, string projectPath) { ArgumentNullException.ThrowIfNull(builder); diff --git a/src/Aspire.Hosting/ResourceBuilderExtensions.cs b/src/Aspire.Hosting/ResourceBuilderExtensions.cs index e4df1c11681..9c47ee8ea3f 100644 --- a/src/Aspire.Hosting/ResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ResourceBuilderExtensions.cs @@ -8,6 +8,7 @@ using System.Security.Cryptography.X509Certificates; using Aspire.Dashboard.Model; using Aspire.Hosting.ApplicationModel; +using Aspire.Hosting.Ats; using Aspire.Hosting.Publishing; using Aspire.Hosting.Utils; using Microsoft.Extensions.DependencyInjection; @@ -351,7 +352,7 @@ public static IResourceBuilder WithEnvironment(this IResourceBuild /// The name of the connection property to annotate. Cannot be null. /// The value of the connection property, specified as a reference expression. /// The same resource builder instance with the connection property annotation applied. - [AspireExport("withConnectionProperty", Description = "Adds a connection property with a reference expression")] + [AspireExportIgnore(Reason = "Polyglot app hosts use the internal withConnectionProperty dispatcher export.")] public static IResourceBuilder WithConnectionProperty(this IResourceBuilder builder, string name, ReferenceExpression value) where T : IResourceWithConnectionString { ArgumentNullException.ThrowIfNull(builder); @@ -369,7 +370,7 @@ public static IResourceBuilder WithConnectionProperty(this IResourceBuilde /// The name of the connection property to add. Cannot be null. /// The value to assign to the connection property. /// The same resource builder instance with the specified connection property annotation applied. - [AspireExport("withConnectionPropertyValue", Description = "Adds a connection property with a string value")] + [AspireExportIgnore(Reason = "Polyglot app hosts use the internal withConnectionProperty dispatcher export.")] public static IResourceBuilder WithConnectionProperty(this IResourceBuilder builder, string name, string value) where T : IResourceWithConnectionString { ArgumentNullException.ThrowIfNull(builder); @@ -378,6 +379,55 @@ public static IResourceBuilder WithConnectionProperty(this IResourceBuilde return builder.WithAnnotation(new ConnectionPropertyAnnotation(name, ReferenceExpression.Create($"{value}"))); } + /// + /// Adds a connection property annotation to the resource being built. + /// + /// The type of resource that implements . + /// The resource builder to which the connection property will be added. + /// The name of the connection property to add. + /// The value to assign to the connection property, specified as a string or reference expression. + /// The same resource builder instance with the specified connection property annotation applied. + [AspireExport("withConnectionProperty", Description = "Adds a connection property with a string or reference expression value")] + internal static IResourceBuilder WithConnectionPropertyExport( + this IResourceBuilder builder, + string name, + [AspireUnion(typeof(string), typeof(ReferenceExpression))] object value) where T : IResourceWithConnectionString + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(name); + ArgumentNullException.ThrowIfNull(value); + + return value switch + { + string stringValue => builder.WithConnectionProperty(name, stringValue), + ReferenceExpression referenceExpression => builder.WithConnectionProperty(name, referenceExpression), + _ => throw new ArgumentException( + $"Unsupported connection property type '{value.GetType().Name}'. Expected string or ReferenceExpression.", + nameof(value)) + }; + } + + /// + /// Adds a connection property annotation to the resource being built. + /// + /// The type of resource that implements . + /// The resource builder to which the connection property will be added. + /// The name of the connection property to add. + /// The string value to assign to the connection property. + /// The same resource builder instance with the specified connection property annotation applied. + [AspireExport("withConnectionPropertyValue", Description = "Adds a connection property with a string value")] + internal static IResourceBuilder WithConnectionPropertyValueExport( + this IResourceBuilder builder, + string name, + string value) where T : IResourceWithConnectionString + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(name); + ArgumentNullException.ThrowIfNull(value); + + return builder.WithConnectionProperty(name, value); + } + /// /// Adds arguments to be passed to a resource that supports arguments when it is launched. /// @@ -586,6 +636,25 @@ public static IResourceBuilder WithReferenceEnvironment + /// Configures how information is injected into environment variables when the resource references other resources. + /// + /// The destination resource. + /// The resource to configure. + /// Options controlling which reference information is emitted. + /// The . + [AspireExport("withReferenceEnvironment", Description = "Configures which reference values are injected into environment variables")] + internal static IResourceBuilder WithReferenceEnvironmentExport( + this IResourceBuilder builder, + ReferenceEnvironmentInjectionOptions options) + where TDestination : IResourceWithEnvironment + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(options); + + return builder.WithReferenceEnvironment(options.ToFlags()); + } + [AspireExport("withReference", Description = "Adds a reference to another resource")] internal static IResourceBuilder WithReference( this IResourceBuilder builder, @@ -3054,6 +3123,26 @@ public static IResourceBuilder WithRelationship( return builder.WithAnnotation(new ResourceRelationshipAnnotation(resource, type)); } + /// + /// Adds a relationship to another resource using its builder. + /// + /// The type of the resource. + /// The resource builder. + /// The resource builder that the relationship is to. + /// The relationship type. + /// A resource builder. + [AspireExport("withBuilderRelationship", MethodName = "withRelationship", Description = "Adds a relationship to another resource")] + public static IResourceBuilder WithRelationship( + this IResourceBuilder builder, + IResourceBuilder resourceBuilder, + string type) where T : IResource + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(resourceBuilder); + + return builder.WithRelationship(resourceBuilder.Resource, type); + } + /// /// Adds a to the resource annotations to add a reference to another resource. /// diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs index 55e016d5ab4..6877da363b1 100644 --- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs +++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Xml.Linq; using Aspire.Cli.Tests.Utils; using Hex1b.Automation; @@ -12,6 +13,8 @@ namespace Aspire.Cli.EndToEnd.Tests.Helpers; /// internal static class CliE2EAutomatorHelpers { + private static readonly string s_expectedStableVersionMarker = GetExpectedStableVersionMarker(); + /// /// Prepares the Docker environment by setting up prompt counting, umask, and environment variables. /// @@ -156,28 +159,39 @@ internal static async Task VerifyAspireCliVersionAsync( string commitSha, SequenceCounter counter) { - var versionPrefix = CliE2ETestHelpers.GetVersionPrefix(); - var isStabilized = CliE2ETestHelpers.IsStabilizedBuild(); + if (commitSha.Length != 40) + { + throw new ArgumentException($"Commit SHA must be exactly 40 characters, got {commitSha.Length}: '{commitSha}'", nameof(commitSha)); + } + + var shortCommitSha = commitSha[..8]; await auto.TypeAsync("aspire --version"); await auto.EnterAsync(); - // Always verify the version prefix matches the branch's version (e.g., "13.3.0"). - await auto.WaitUntilTextAsync(versionPrefix, timeout: TimeSpan.FromSeconds(10)); - - // For non-stabilized builds (all PR CI builds), also verify the commit SHA suffix - // to uniquely identify the exact build. Stabilized builds (official releases only) - // produce versions without SHA suffixes, so we skip this check. - if (!isStabilized && commitSha.Length == 40) - { - var shortCommitSha = commitSha[..8]; - var expectedVersionSuffix = $"g{shortCommitSha}"; - await auto.WaitUntilTextAsync(expectedVersionSuffix, timeout: TimeSpan.FromSeconds(10)); - } + // Stabilized PR builds can omit the commit SHA from the printed version, so accept + // either the expected major/minor marker from eng/Versions.props or the PR commit SHA. + await auto.WaitUntilAsync( + snapshot => snapshot.ContainsText(s_expectedStableVersionMarker) || snapshot.ContainsText($"g{shortCommitSha}"), + timeout: TimeSpan.FromSeconds(10), + description: $"Aspire CLI version containing '{s_expectedStableVersionMarker}' or 'g{shortCommitSha}'"); await auto.WaitForSuccessPromptAsync(counter); } + private static string GetExpectedStableVersionMarker() + { + var versionsPropsPath = Path.Combine(CliE2ETestHelpers.GetRepoRoot(), "eng", "Versions.props"); + var document = XDocument.Load(versionsPropsPath); + + var majorVersion = document.Descendants("MajorVersion").FirstOrDefault()?.Value; + var minorVersion = document.Descendants("MinorVersion").FirstOrDefault()?.Value; + + return !string.IsNullOrEmpty(majorVersion) && !string.IsNullOrEmpty(minorVersion) + ? $"{majorVersion}.{minorVersion}." + : throw new InvalidOperationException($"Could not determine Aspire version marker from '{versionsPropsPath}'."); + } + /// /// Installs the Aspire CLI and bundle from PR build artifacts, using the PR head SHA to fetch the install script. /// diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/AtsGoCodeGeneratorTests.cs b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/AtsGoCodeGeneratorTests.cs index 409a85ef74f..95ce7152c96 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/AtsGoCodeGeneratorTests.cs +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/AtsGoCodeGeneratorTests.cs @@ -255,11 +255,23 @@ public void GeneratedCode_HasGoModFile() var atsContext = CreateContextFromBothAssemblies(); var files = _generator.GenerateDistributedApplication(atsContext); - + Assert.Contains("go.mod", files.Keys); Assert.Contains("module apphost/modules/aspire", files["go.mod"]); } + [Fact] + public void GenerateDistributedApplication_HostingAssembly_SanitizesGoKeywordParameters() + { + var atsContext = CreateContextFromBothAssemblies(); + + var files = _generator.GenerateDistributedApplication(atsContext); + var aspireGo = files["aspire.go"]; + + Assert.Matches(@"func \(s \*[^\)]*\) WithRelationship\([^)]*type_ string\)", aspireGo); + Assert.DoesNotMatch(@"func \(s \*[^\)]*\) WithRelationship\([^)]*\btype string\)", aspireGo); + } + private static List ScanCapabilitiesFromTestAssembly() { var testAssembly = LoadTestAssembly(); diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/HostingAddContainerCapability.verified.txt b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/HostingAddContainerCapability.verified.txt index aa3dae2c23d..61f69575bbb 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/HostingAddContainerCapability.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/HostingAddContainerCapability.verified.txt @@ -22,13 +22,34 @@ { Name: image, Type: { - TypeId: string, - ClrType: string, + TypeId: string|Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + Category: Union, IsInterface: false, IsReadOnly: false, IsResourceBuilder: false, IsDistributedApplicationBuilder: false, - IsDistributedApplication: false + IsDistributedApplication: false, + UnionTypes: [ + { + TypeId: string, + ClrType: string, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + }, + { + TypeId: Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + ClrType: AddContainerOptions, + Category: Dto, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + } + ] }, IsOptional: false, IsNullable: false, @@ -70,6 +91,6 @@ } ], ReturnsBuilder: true, - SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainer, + SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainerForPolyglot, RunSyncOnBackgroundThread: false } \ No newline at end of file diff --git a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go index b63084eea8b..20c65e73177 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go +++ b/tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go @@ -158,6 +158,20 @@ const ( // DTOs // ============================================================================ +// AddContainerOptions represents AddContainerOptions. +type AddContainerOptions struct { + Image string `json:"Image,omitempty"` + Tag string `json:"Tag,omitempty"` +} + +// ToMap converts the DTO to a map for JSON serialization. +func (d *AddContainerOptions) ToMap() map[string]any { + return map[string]any{ + "Image": SerializeValue(d.Image), + "Tag": SerializeValue(d.Tag), + } +} + // CreateBuilderOptions represents CreateBuilderOptions. type CreateBuilderOptions struct { Args []string `json:"Args,omitempty"` @@ -206,6 +220,24 @@ func (d *ResourceEventDto) ToMap() map[string]any { } } +// ReferenceEnvironmentInjectionOptions represents ReferenceEnvironmentInjectionOptions. +type ReferenceEnvironmentInjectionOptions struct { + ConnectionString bool `json:"ConnectionString,omitempty"` + ConnectionProperties bool `json:"ConnectionProperties,omitempty"` + ServiceDiscovery bool `json:"ServiceDiscovery,omitempty"` + Endpoints bool `json:"Endpoints,omitempty"` +} + +// ToMap converts the DTO to a map for JSON serialization. +func (d *ReferenceEnvironmentInjectionOptions) ToMap() map[string]any { + return map[string]any{ + "ConnectionString": SerializeValue(d.ConnectionString), + "ConnectionProperties": SerializeValue(d.ConnectionProperties), + "ServiceDiscovery": SerializeValue(d.ServiceDiscovery), + "Endpoints": SerializeValue(d.Endpoints), + } +} + // CommandOptions represents CommandOptions. type CommandOptions struct { Description string `json:"Description,omitempty"` @@ -230,6 +262,34 @@ func (d *CommandOptions) ToMap() map[string]any { } } +// GenerateParameterDefault represents GenerateParameterDefault. +type GenerateParameterDefault struct { + MinLength float64 `json:"MinLength,omitempty"` + Lower bool `json:"Lower,omitempty"` + Upper bool `json:"Upper,omitempty"` + Numeric bool `json:"Numeric,omitempty"` + Special bool `json:"Special,omitempty"` + MinLower float64 `json:"MinLower,omitempty"` + MinUpper float64 `json:"MinUpper,omitempty"` + MinNumeric float64 `json:"MinNumeric,omitempty"` + MinSpecial float64 `json:"MinSpecial,omitempty"` +} + +// ToMap converts the DTO to a map for JSON serialization. +func (d *GenerateParameterDefault) ToMap() map[string]any { + return map[string]any{ + "MinLength": SerializeValue(d.MinLength), + "Lower": SerializeValue(d.Lower), + "Upper": SerializeValue(d.Upper), + "Numeric": SerializeValue(d.Numeric), + "Special": SerializeValue(d.Special), + "MinLower": SerializeValue(d.MinLower), + "MinUpper": SerializeValue(d.MinUpper), + "MinNumeric": SerializeValue(d.MinNumeric), + "MinSpecial": SerializeValue(d.MinSpecial), + } +} + // ExecuteCommandResult represents ExecuteCommandResult. type ExecuteCommandResult struct { Success bool `json:"Success,omitempty"` @@ -682,6 +742,19 @@ func (s *CSharpAppResource) WithArgsCallbackAsync(callback func(...any) any) (*I return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *CSharpAppResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *CSharpAppResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -1180,6 +1253,20 @@ func (s *CSharpAppResource) WithoutHttpsCertificate() (*IResourceWithEnvironment return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *CSharpAppResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *CSharpAppResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -1837,8 +1924,8 @@ func (s *ConnectionStringResource) WithRequiredCommand(command string, helpLink return result.(*IResource), nil } -// WithConnectionProperty adds a connection property with a reference expression -func (s *ConnectionStringResource) WithConnectionProperty(name string, value *ReferenceExpression) (*IResourceWithConnectionString, error) { +// WithConnectionProperty adds a connection property with a string or reference expression value +func (s *ConnectionStringResource) WithConnectionProperty(name string, value any) (*IResourceWithConnectionString, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } @@ -2083,6 +2170,20 @@ func (s *ConnectionStringResource) WithCommand(name string, displayName string, return result.(*IResource), nil } +// WithRelationship adds a relationship to another resource +func (s *ConnectionStringResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *ConnectionStringResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -2682,6 +2783,20 @@ func (s *ContainerRegistryResource) WithCommand(name string, displayName string, return result.(*IResource), nil } +// WithRelationship adds a relationship to another resource +func (s *ContainerRegistryResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *ContainerRegistryResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -3239,14 +3354,14 @@ func (s *ContainerResource) WithContainerName(name string) (*ContainerResource, return result.(*ContainerResource), nil } -// WithBuildArg adds a build argument from a parameter resource -func (s *ContainerResource) WithBuildArg(name string, value *ParameterResource) (*ContainerResource, error) { +// WithBuildArg adds a build argument from a string value or parameter resource +func (s *ContainerResource) WithBuildArg(name string, value any) (*ContainerResource, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) if err != nil { return nil, err } @@ -3267,6 +3382,27 @@ func (s *ContainerResource) WithBuildSecret(name string, value *ParameterResourc return result.(*ContainerResource), nil } +// WithContainerCertificatePaths overrides container certificate bundle and directory paths used for trust configuration +func (s *ContainerResource) WithContainerCertificatePaths(customCertificatesDestination *string, defaultCertificateBundlePaths []string, defaultCertificateDirectoryPaths []string) (*ContainerResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + if customCertificatesDestination != nil { + reqArgs["customCertificatesDestination"] = SerializeValue(customCertificatesDestination) + } + if defaultCertificateBundlePaths != nil { + reqArgs["defaultCertificateBundlePaths"] = SerializeValue(defaultCertificateBundlePaths) + } + if defaultCertificateDirectoryPaths != nil { + reqArgs["defaultCertificateDirectoryPaths"] = SerializeValue(defaultCertificateDirectoryPaths) + } + result, err := s.Client().InvokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs) + if err != nil { + return nil, err + } + return result.(*ContainerResource), nil +} + // WithEndpointProxySupport configures endpoint proxy support func (s *ContainerResource) WithEndpointProxySupport(proxyEnabled bool) (*ContainerResource, error) { reqArgs := map[string]any{ @@ -3496,6 +3632,19 @@ func (s *ContainerResource) WithArgsCallbackAsync(callback func(...any) any) (*I return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *ContainerResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *ContainerResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -3980,6 +4129,20 @@ func (s *ContainerResource) WithoutHttpsCertificate() (*IResourceWithEnvironment return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *ContainerResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *ContainerResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -4992,6 +5155,19 @@ func (s *DotnetToolResource) WithArgsCallbackAsync(callback func(...any) any) (* return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *DotnetToolResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *DotnetToolResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -5476,6 +5652,20 @@ func (s *DotnetToolResource) WithoutHttpsCertificate() (*IResourceWithEnvironmen return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *DotnetToolResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *DotnetToolResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -6564,6 +6754,19 @@ func (s *ExecutableResource) WithArgsCallbackAsync(callback func(...any) any) (* return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *ExecutableResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *ExecutableResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -7048,6 +7251,20 @@ func (s *ExecutableResource) WithoutHttpsCertificate() (*IResourceWithEnvironmen return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *ExecutableResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *ExecutableResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -7816,6 +8033,20 @@ func (s *ExternalServiceResource) WithCommand(name string, displayName string, e return result.(*IResource), nil } +// WithRelationship adds a relationship to another resource +func (s *ExternalServiceResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *ExternalServiceResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -8369,7 +8600,7 @@ func (s *IDistributedApplicationBuilder) AddContainerRegistryFromString(name str } // AddContainer adds a container resource -func (s *IDistributedApplicationBuilder) AddContainer(name string, image string) (*ContainerResource, error) { +func (s *IDistributedApplicationBuilder) AddContainer(name string, image any) (*ContainerResource, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } @@ -8599,6 +8830,26 @@ func (s *IDistributedApplicationBuilder) AddParameterFromConfiguration(name stri return result.(*ParameterResource), nil } +// AddParameterWithGeneratedValue adds a parameter with a generated default value +func (s *IDistributedApplicationBuilder) AddParameterWithGeneratedValue(name string, value *GenerateParameterDefault, secret *bool, persist *bool) (*ParameterResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["name"] = SerializeValue(name) + reqArgs["value"] = SerializeValue(value) + if secret != nil { + reqArgs["secret"] = SerializeValue(secret) + } + if persist != nil { + reqArgs["persist"] = SerializeValue(persist) + } + result, err := s.Client().InvokeCapability("Aspire.Hosting/addParameterWithGeneratedValue", reqArgs) + if err != nil { + return nil, err + } + return result.(*ParameterResource), nil +} + // AddConnectionString adds a connection string resource func (s *IDistributedApplicationBuilder) AddConnectionString(name string, environmentVariableName *string) (*IResourceWithConnectionString, error) { reqArgs := map[string]any{ @@ -8615,6 +8866,20 @@ func (s *IDistributedApplicationBuilder) AddConnectionString(name string, enviro return result.(*IResourceWithConnectionString), nil } +// AddProjectWithoutLaunchProfile adds a .NET project resource without a launch profile +func (s *IDistributedApplicationBuilder) AddProjectWithoutLaunchProfile(name string, projectPath string) (*ProjectResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["name"] = SerializeValue(name) + reqArgs["projectPath"] = SerializeValue(projectPath) + result, err := s.Client().InvokeCapability("Aspire.Hosting/addProjectWithoutLaunchProfile", reqArgs) + if err != nil { + return nil, err + } + return result.(*ProjectResource), nil +} + // AddProject adds a .NET project resource func (s *IDistributedApplicationBuilder) AddProject(name string, projectPath string, launchProfileName string) (*ProjectResource, error) { reqArgs := map[string]any{ @@ -9688,6 +9953,20 @@ func (s *ParameterResource) WithCommand(name string, displayName string, execute return result.(*IResource), nil } +// WithRelationship adds a relationship to another resource +func (s *ParameterResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *ParameterResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -10910,6 +11189,19 @@ func (s *ProjectResource) WithArgsCallbackAsync(callback func(...any) any) (*IRe return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *ProjectResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *ProjectResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -11408,6 +11700,20 @@ func (s *ProjectResource) WithoutHttpsCertificate() (*IResourceWithEnvironment, return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *ProjectResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *ProjectResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -12659,14 +12965,14 @@ func (s *TestDatabaseResource) WithContainerName(name string) (*ContainerResourc return result.(*ContainerResource), nil } -// WithBuildArg adds a build argument from a parameter resource -func (s *TestDatabaseResource) WithBuildArg(name string, value *ParameterResource) (*ContainerResource, error) { +// WithBuildArg adds a build argument from a string value or parameter resource +func (s *TestDatabaseResource) WithBuildArg(name string, value any) (*ContainerResource, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) if err != nil { return nil, err } @@ -12687,6 +12993,27 @@ func (s *TestDatabaseResource) WithBuildSecret(name string, value *ParameterReso return result.(*ContainerResource), nil } +// WithContainerCertificatePaths overrides container certificate bundle and directory paths used for trust configuration +func (s *TestDatabaseResource) WithContainerCertificatePaths(customCertificatesDestination *string, defaultCertificateBundlePaths []string, defaultCertificateDirectoryPaths []string) (*ContainerResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + if customCertificatesDestination != nil { + reqArgs["customCertificatesDestination"] = SerializeValue(customCertificatesDestination) + } + if defaultCertificateBundlePaths != nil { + reqArgs["defaultCertificateBundlePaths"] = SerializeValue(defaultCertificateBundlePaths) + } + if defaultCertificateDirectoryPaths != nil { + reqArgs["defaultCertificateDirectoryPaths"] = SerializeValue(defaultCertificateDirectoryPaths) + } + result, err := s.Client().InvokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs) + if err != nil { + return nil, err + } + return result.(*ContainerResource), nil +} + // WithEndpointProxySupport configures endpoint proxy support func (s *TestDatabaseResource) WithEndpointProxySupport(proxyEnabled bool) (*ContainerResource, error) { reqArgs := map[string]any{ @@ -12916,6 +13243,19 @@ func (s *TestDatabaseResource) WithArgsCallbackAsync(callback func(...any) any) return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *TestDatabaseResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *TestDatabaseResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -13400,6 +13740,20 @@ func (s *TestDatabaseResource) WithoutHttpsCertificate() (*IResourceWithEnvironm return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *TestDatabaseResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *TestDatabaseResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -14168,14 +14522,14 @@ func (s *TestRedisResource) WithContainerName(name string) (*ContainerResource, return result.(*ContainerResource), nil } -// WithBuildArg adds a build argument from a parameter resource -func (s *TestRedisResource) WithBuildArg(name string, value *ParameterResource) (*ContainerResource, error) { +// WithBuildArg adds a build argument from a string value or parameter resource +func (s *TestRedisResource) WithBuildArg(name string, value any) (*ContainerResource, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) if err != nil { return nil, err } @@ -14196,6 +14550,27 @@ func (s *TestRedisResource) WithBuildSecret(name string, value *ParameterResourc return result.(*ContainerResource), nil } +// WithContainerCertificatePaths overrides container certificate bundle and directory paths used for trust configuration +func (s *TestRedisResource) WithContainerCertificatePaths(customCertificatesDestination *string, defaultCertificateBundlePaths []string, defaultCertificateDirectoryPaths []string) (*ContainerResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + if customCertificatesDestination != nil { + reqArgs["customCertificatesDestination"] = SerializeValue(customCertificatesDestination) + } + if defaultCertificateBundlePaths != nil { + reqArgs["defaultCertificateBundlePaths"] = SerializeValue(defaultCertificateBundlePaths) + } + if defaultCertificateDirectoryPaths != nil { + reqArgs["defaultCertificateDirectoryPaths"] = SerializeValue(defaultCertificateDirectoryPaths) + } + result, err := s.Client().InvokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs) + if err != nil { + return nil, err + } + return result.(*ContainerResource), nil +} + // WithEndpointProxySupport configures endpoint proxy support func (s *TestRedisResource) WithEndpointProxySupport(proxyEnabled bool) (*ContainerResource, error) { reqArgs := map[string]any{ @@ -14382,8 +14757,8 @@ func (s *TestRedisResource) WithEnvironmentConnectionString(envVarName string, r return result.(*IResourceWithEnvironment), nil } -// WithConnectionProperty adds a connection property with a reference expression -func (s *TestRedisResource) WithConnectionProperty(name string, value *ReferenceExpression) (*IResourceWithConnectionString, error) { +// WithConnectionProperty adds a connection property with a string or reference expression value +func (s *TestRedisResource) WithConnectionProperty(name string, value any) (*IResourceWithConnectionString, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } @@ -14453,6 +14828,19 @@ func (s *TestRedisResource) WithArgsCallbackAsync(callback func(...any) any) (*I return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *TestRedisResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *TestRedisResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -14950,6 +15338,20 @@ func (s *TestRedisResource) WithoutHttpsCertificate() (*IResourceWithEnvironment return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *TestRedisResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *TestRedisResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ @@ -15902,14 +16304,14 @@ func (s *TestVaultResource) WithContainerName(name string) (*ContainerResource, return result.(*ContainerResource), nil } -// WithBuildArg adds a build argument from a parameter resource -func (s *TestVaultResource) WithBuildArg(name string, value *ParameterResource) (*ContainerResource, error) { +// WithBuildArg adds a build argument from a string value or parameter resource +func (s *TestVaultResource) WithBuildArg(name string, value any) (*ContainerResource, error) { reqArgs := map[string]any{ "builder": SerializeValue(s.Handle()), } reqArgs["name"] = SerializeValue(name) reqArgs["value"] = SerializeValue(value) - result, err := s.Client().InvokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs) if err != nil { return nil, err } @@ -15930,6 +16332,27 @@ func (s *TestVaultResource) WithBuildSecret(name string, value *ParameterResourc return result.(*ContainerResource), nil } +// WithContainerCertificatePaths overrides container certificate bundle and directory paths used for trust configuration +func (s *TestVaultResource) WithContainerCertificatePaths(customCertificatesDestination *string, defaultCertificateBundlePaths []string, defaultCertificateDirectoryPaths []string) (*ContainerResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + if customCertificatesDestination != nil { + reqArgs["customCertificatesDestination"] = SerializeValue(customCertificatesDestination) + } + if defaultCertificateBundlePaths != nil { + reqArgs["defaultCertificateBundlePaths"] = SerializeValue(defaultCertificateBundlePaths) + } + if defaultCertificateDirectoryPaths != nil { + reqArgs["defaultCertificateDirectoryPaths"] = SerializeValue(defaultCertificateDirectoryPaths) + } + result, err := s.Client().InvokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs) + if err != nil { + return nil, err + } + return result.(*ContainerResource), nil +} + // WithEndpointProxySupport configures endpoint proxy support func (s *TestVaultResource) WithEndpointProxySupport(proxyEnabled bool) (*ContainerResource, error) { reqArgs := map[string]any{ @@ -16159,6 +16582,19 @@ func (s *TestVaultResource) WithArgsCallbackAsync(callback func(...any) any) (*I return result.(*IResourceWithArgs), nil } +// WithReferenceEnvironment configures which reference values are injected into environment variables +func (s *TestVaultResource) WithReferenceEnvironment(options *ReferenceEnvironmentInjectionOptions) (*IResourceWithEnvironment, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["options"] = SerializeValue(options) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResourceWithEnvironment), nil +} + // WithReference adds a reference to another resource func (s *TestVaultResource) WithReference(source *IResource, connectionName *string, optional *bool, name *string) (*IResourceWithEnvironment, error) { reqArgs := map[string]any{ @@ -16643,6 +17079,20 @@ func (s *TestVaultResource) WithoutHttpsCertificate() (*IResourceWithEnvironment return result.(*IResourceWithEnvironment), nil } +// WithRelationship adds a relationship to another resource +func (s *TestVaultResource) WithRelationship(resourceBuilder *IResource, type_ string) (*IResource, error) { + reqArgs := map[string]any{ + "builder": SerializeValue(s.Handle()), + } + reqArgs["resourceBuilder"] = SerializeValue(resourceBuilder) + reqArgs["type"] = SerializeValue(type_) + result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs) + if err != nil { + return nil, err + } + return result.(*IResource), nil +} + // WithParentRelationship sets the parent relationship func (s *TestVaultResource) WithParentRelationship(parent *IResource) (*IResource, error) { reqArgs := map[string]any{ diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/HostingAddContainerCapability.verified.txt b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/HostingAddContainerCapability.verified.txt index aa3dae2c23d..61f69575bbb 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/HostingAddContainerCapability.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/HostingAddContainerCapability.verified.txt @@ -22,13 +22,34 @@ { Name: image, Type: { - TypeId: string, - ClrType: string, + TypeId: string|Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + Category: Union, IsInterface: false, IsReadOnly: false, IsResourceBuilder: false, IsDistributedApplicationBuilder: false, - IsDistributedApplication: false + IsDistributedApplication: false, + UnionTypes: [ + { + TypeId: string, + ClrType: string, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + }, + { + TypeId: Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + ClrType: AddContainerOptions, + Category: Dto, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + } + ] }, IsOptional: false, IsNullable: false, @@ -70,6 +91,6 @@ } ], ReturnsBuilder: true, - SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainer, + SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainerForPolyglot, RunSyncOnBackgroundThread: false } \ No newline at end of file diff --git a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java index e696b870cf5..de2edd858e6 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java +++ b/tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java @@ -325,6 +325,24 @@ public static TestResourceStatus fromValue(String value) { // DTOs // ============================================================================ +/** AddContainerOptions DTO. */ +class AddContainerOptions { + private String image; + private String tag; + + public String getImage() { return image; } + public void setImage(String value) { this.image = value; } + public String getTag() { return tag; } + public void setTag(String value) { this.tag = value; } + + public Map toMap() { + Map map = new HashMap<>(); + map.put("Image", AspireClient.serializeValue(image)); + map.put("Tag", AspireClient.serializeValue(tag)); + return map; + } +} + /** CreateBuilderOptions DTO. */ class CreateBuilderOptions { private String[] args; @@ -401,6 +419,32 @@ public Map toMap() { } } +/** ReferenceEnvironmentInjectionOptions DTO. */ +class ReferenceEnvironmentInjectionOptions { + private boolean connectionString; + private boolean connectionProperties; + private boolean serviceDiscovery; + private boolean endpoints; + + public boolean getConnectionString() { return connectionString; } + public void setConnectionString(boolean value) { this.connectionString = value; } + public boolean getConnectionProperties() { return connectionProperties; } + public void setConnectionProperties(boolean value) { this.connectionProperties = value; } + public boolean getServiceDiscovery() { return serviceDiscovery; } + public void setServiceDiscovery(boolean value) { this.serviceDiscovery = value; } + public boolean getEndpoints() { return endpoints; } + public void setEndpoints(boolean value) { this.endpoints = value; } + + public Map toMap() { + Map map = new HashMap<>(); + map.put("ConnectionString", AspireClient.serializeValue(connectionString)); + map.put("ConnectionProperties", AspireClient.serializeValue(connectionProperties)); + map.put("ServiceDiscovery", AspireClient.serializeValue(serviceDiscovery)); + map.put("Endpoints", AspireClient.serializeValue(endpoints)); + return map; + } +} + /** CommandOptions DTO. */ class CommandOptions { private String description; @@ -439,6 +483,52 @@ public Map toMap() { } } +/** GenerateParameterDefault DTO. */ +class GenerateParameterDefault { + private double minLength; + private boolean lower; + private boolean upper; + private boolean numeric; + private boolean special; + private double minLower; + private double minUpper; + private double minNumeric; + private double minSpecial; + + public double getMinLength() { return minLength; } + public void setMinLength(double value) { this.minLength = value; } + public boolean getLower() { return lower; } + public void setLower(boolean value) { this.lower = value; } + public boolean getUpper() { return upper; } + public void setUpper(boolean value) { this.upper = value; } + public boolean getNumeric() { return numeric; } + public void setNumeric(boolean value) { this.numeric = value; } + public boolean getSpecial() { return special; } + public void setSpecial(boolean value) { this.special = value; } + public double getMinLower() { return minLower; } + public void setMinLower(double value) { this.minLower = value; } + public double getMinUpper() { return minUpper; } + public void setMinUpper(double value) { this.minUpper = value; } + public double getMinNumeric() { return minNumeric; } + public void setMinNumeric(double value) { this.minNumeric = value; } + public double getMinSpecial() { return minSpecial; } + public void setMinSpecial(double value) { this.minSpecial = value; } + + public Map toMap() { + Map map = new HashMap<>(); + map.put("MinLength", AspireClient.serializeValue(minLength)); + map.put("Lower", AspireClient.serializeValue(lower)); + map.put("Upper", AspireClient.serializeValue(upper)); + map.put("Numeric", AspireClient.serializeValue(numeric)); + map.put("Special", AspireClient.serializeValue(special)); + map.put("MinLower", AspireClient.serializeValue(minLower)); + map.put("MinUpper", AspireClient.serializeValue(minUpper)); + map.put("MinNumeric", AspireClient.serializeValue(minNumeric)); + map.put("MinSpecial", AspireClient.serializeValue(minSpecial)); + return map; + } +} + /** ExecuteCommandResult DTO. */ class ExecuteCommandResult { private boolean success; @@ -792,6 +882,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -1135,6 +1233,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -1570,8 +1677,8 @@ public IResource withRequiredCommand(String command, String helpLink) { return (IResource) getClient().invokeCapability("Aspire.Hosting/withRequiredCommand", reqArgs); } - /** Adds a connection property with a reference expression */ - public IResourceWithConnectionString withConnectionProperty(String name, ReferenceExpression value) { + /** Adds a connection property with a string or reference expression value */ + public IResourceWithConnectionString withConnectionProperty(String name, Object value) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); @@ -1731,6 +1838,15 @@ public IResource withCommand(String name, String displayName, Function reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -2126,6 +2242,15 @@ public IResource withCommand(String name, String displayName, Function reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -2489,13 +2614,13 @@ public ContainerResource withContainerName(String name) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerName", reqArgs); } - /** Adds a build argument from a parameter resource */ - public ContainerResource withBuildArg(String name, ParameterResource value) { + /** Adds a build argument from a string value or parameter resource */ + public ContainerResource withBuildArg(String name, Object value) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -2507,6 +2632,22 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + public ContainerResource withContainerCertificatePaths(String customCertificatesDestination, String[] defaultCertificateBundlePaths, String[] defaultCertificateDirectoryPaths) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + if (customCertificatesDestination != null) { + reqArgs.put("customCertificatesDestination", AspireClient.serializeValue(customCertificatesDestination)); + } + if (defaultCertificateBundlePaths != null) { + reqArgs.put("defaultCertificateBundlePaths", AspireClient.serializeValue(defaultCertificateBundlePaths)); + } + if (defaultCertificateDirectoryPaths != null) { + reqArgs.put("defaultCertificateDirectoryPaths", AspireClient.serializeValue(defaultCertificateDirectoryPaths)); + } + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs); + } + /** Configures endpoint proxy support */ public ContainerResource withEndpointProxySupport(boolean proxyEnabled) { Map reqArgs = new HashMap<>(); @@ -2656,6 +2797,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -2990,6 +3139,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -3652,6 +3810,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -3986,6 +4152,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -4688,6 +4863,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -5022,6 +5205,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -5532,6 +5724,15 @@ public IResource withCommand(String name, String displayName, Function reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -5895,7 +6096,7 @@ public ContainerRegistryResource addContainerRegistryFromString(String name, Str } /** Adds a container resource */ - public ContainerResource addContainer(String name, String image) { + public ContainerResource addContainer(String name, Object image) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); @@ -6045,6 +6246,21 @@ public ParameterResource addParameterFromConfiguration(String name, String confi return (ParameterResource) getClient().invokeCapability("Aspire.Hosting/addParameterFromConfiguration", reqArgs); } + /** Adds a parameter with a generated default value */ + public ParameterResource addParameterWithGeneratedValue(String name, GenerateParameterDefault value, Boolean secret, Boolean persist) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("value", AspireClient.serializeValue(value)); + if (secret != null) { + reqArgs.put("secret", AspireClient.serializeValue(secret)); + } + if (persist != null) { + reqArgs.put("persist", AspireClient.serializeValue(persist)); + } + return (ParameterResource) getClient().invokeCapability("Aspire.Hosting/addParameterWithGeneratedValue", reqArgs); + } + /** Adds a connection string resource */ public IResourceWithConnectionString addConnectionString(String name, String environmentVariableName) { Map reqArgs = new HashMap<>(); @@ -6056,6 +6272,15 @@ public IResourceWithConnectionString addConnectionString(String name, String env return (IResourceWithConnectionString) getClient().invokeCapability("Aspire.Hosting/addConnectionString", reqArgs); } + /** Adds a .NET project resource without a launch profile */ + public ProjectResource addProjectWithoutLaunchProfile(String name, String projectPath) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("name", AspireClient.serializeValue(name)); + reqArgs.put("projectPath", AspireClient.serializeValue(projectPath)); + return (ProjectResource) getClient().invokeCapability("Aspire.Hosting/addProjectWithoutLaunchProfile", reqArgs); + } + /** Adds a .NET project resource */ public ProjectResource addProject(String name, String projectPath, String launchProfileName) { Map reqArgs = new HashMap<>(); @@ -6788,6 +7013,15 @@ public IResource withCommand(String name, String displayName, Function reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -7579,6 +7813,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -7922,6 +8164,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -8753,13 +9004,13 @@ public ContainerResource withContainerName(String name) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerName", reqArgs); } - /** Adds a build argument from a parameter resource */ - public ContainerResource withBuildArg(String name, ParameterResource value) { + /** Adds a build argument from a string value or parameter resource */ + public ContainerResource withBuildArg(String name, Object value) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -8771,6 +9022,22 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + public ContainerResource withContainerCertificatePaths(String customCertificatesDestination, String[] defaultCertificateBundlePaths, String[] defaultCertificateDirectoryPaths) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + if (customCertificatesDestination != null) { + reqArgs.put("customCertificatesDestination", AspireClient.serializeValue(customCertificatesDestination)); + } + if (defaultCertificateBundlePaths != null) { + reqArgs.put("defaultCertificateBundlePaths", AspireClient.serializeValue(defaultCertificateBundlePaths)); + } + if (defaultCertificateDirectoryPaths != null) { + reqArgs.put("defaultCertificateDirectoryPaths", AspireClient.serializeValue(defaultCertificateDirectoryPaths)); + } + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs); + } + /** Configures endpoint proxy support */ public ContainerResource withEndpointProxySupport(boolean proxyEnabled) { Map reqArgs = new HashMap<>(); @@ -8920,6 +9187,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -9254,6 +9529,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -9757,13 +10041,13 @@ public ContainerResource withContainerName(String name) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerName", reqArgs); } - /** Adds a build argument from a parameter resource */ - public ContainerResource withBuildArg(String name, ParameterResource value) { + /** Adds a build argument from a string value or parameter resource */ + public ContainerResource withBuildArg(String name, Object value) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -9775,6 +10059,22 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + public ContainerResource withContainerCertificatePaths(String customCertificatesDestination, String[] defaultCertificateBundlePaths, String[] defaultCertificateDirectoryPaths) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + if (customCertificatesDestination != null) { + reqArgs.put("customCertificatesDestination", AspireClient.serializeValue(customCertificatesDestination)); + } + if (defaultCertificateBundlePaths != null) { + reqArgs.put("defaultCertificateBundlePaths", AspireClient.serializeValue(defaultCertificateBundlePaths)); + } + if (defaultCertificateDirectoryPaths != null) { + reqArgs.put("defaultCertificateDirectoryPaths", AspireClient.serializeValue(defaultCertificateDirectoryPaths)); + } + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs); + } + /** Configures endpoint proxy support */ public ContainerResource withEndpointProxySupport(boolean proxyEnabled) { Map reqArgs = new HashMap<>(); @@ -9896,8 +10196,8 @@ public IResourceWithEnvironment withEnvironmentConnectionString(String envVarNam return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withEnvironmentConnectionString", reqArgs); } - /** Adds a connection property with a reference expression */ - public IResourceWithConnectionString withConnectionProperty(String name, ReferenceExpression value) { + /** Adds a connection property with a string or reference expression value */ + public IResourceWithConnectionString withConnectionProperty(String name, Object value) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); @@ -9942,6 +10242,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -10284,6 +10592,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); @@ -10918,13 +11235,13 @@ public ContainerResource withContainerName(String name) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerName", reqArgs); } - /** Adds a build argument from a parameter resource */ - public ContainerResource withBuildArg(String name, ParameterResource value) { + /** Adds a build argument from a string value or parameter resource */ + public ContainerResource withBuildArg(String name, Object value) { Map reqArgs = new HashMap<>(); reqArgs.put("builder", AspireClient.serializeValue(getHandle())); reqArgs.put("name", AspireClient.serializeValue(name)); reqArgs.put("value", AspireClient.serializeValue(value)); - return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildArg", reqArgs); + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withBuildArg", reqArgs); } /** Adds a build secret from a parameter resource */ @@ -10936,6 +11253,22 @@ public ContainerResource withBuildSecret(String name, ParameterResource value) { return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withParameterBuildSecret", reqArgs); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + public ContainerResource withContainerCertificatePaths(String customCertificatesDestination, String[] defaultCertificateBundlePaths, String[] defaultCertificateDirectoryPaths) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + if (customCertificatesDestination != null) { + reqArgs.put("customCertificatesDestination", AspireClient.serializeValue(customCertificatesDestination)); + } + if (defaultCertificateBundlePaths != null) { + reqArgs.put("defaultCertificateBundlePaths", AspireClient.serializeValue(defaultCertificateBundlePaths)); + } + if (defaultCertificateDirectoryPaths != null) { + reqArgs.put("defaultCertificateDirectoryPaths", AspireClient.serializeValue(defaultCertificateDirectoryPaths)); + } + return (ContainerResource) getClient().invokeCapability("Aspire.Hosting/withContainerCertificatePaths", reqArgs); + } + /** Configures endpoint proxy support */ public ContainerResource withEndpointProxySupport(boolean proxyEnabled) { Map reqArgs = new HashMap<>(); @@ -11085,6 +11418,14 @@ public IResourceWithArgs withArgsCallbackAsync(Function callba return (IResourceWithArgs) getClient().invokeCapability("Aspire.Hosting/withArgsCallbackAsync", reqArgs); } + /** Configures which reference values are injected into environment variables */ + public IResourceWithEnvironment withReferenceEnvironment(ReferenceEnvironmentInjectionOptions options) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("options", AspireClient.serializeValue(options)); + return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withReferenceEnvironment", reqArgs); + } + /** Adds a reference to another resource */ public IResourceWithEnvironment withReference(IResource source, String connectionName, Boolean optional, String name) { Map reqArgs = new HashMap<>(); @@ -11419,6 +11760,15 @@ public IResourceWithEnvironment withoutHttpsCertificate() { return (IResourceWithEnvironment) getClient().invokeCapability("Aspire.Hosting/withoutHttpsCertificate", reqArgs); } + /** Adds a relationship to another resource */ + public IResource withRelationship(IResource resourceBuilder, String type) { + Map reqArgs = new HashMap<>(); + reqArgs.put("builder", AspireClient.serializeValue(getHandle())); + reqArgs.put("resourceBuilder", AspireClient.serializeValue(resourceBuilder)); + reqArgs.put("type", AspireClient.serializeValue(type)); + return (IResource) getClient().invokeCapability("Aspire.Hosting/withBuilderRelationship", reqArgs); + } + /** Sets the parent relationship */ public IResource withParentRelationship(IResource parent) { Map reqArgs = new HashMap<>(); diff --git a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/HostingAddContainerCapability.verified.txt b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/HostingAddContainerCapability.verified.txt index aa3dae2c23d..61f69575bbb 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/HostingAddContainerCapability.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/HostingAddContainerCapability.verified.txt @@ -22,13 +22,34 @@ { Name: image, Type: { - TypeId: string, - ClrType: string, + TypeId: string|Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + Category: Union, IsInterface: false, IsReadOnly: false, IsResourceBuilder: false, IsDistributedApplicationBuilder: false, - IsDistributedApplication: false + IsDistributedApplication: false, + UnionTypes: [ + { + TypeId: string, + ClrType: string, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + }, + { + TypeId: Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + ClrType: AddContainerOptions, + Category: Dto, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + } + ] }, IsOptional: false, IsNullable: false, @@ -70,6 +91,6 @@ } ], ReturnsBuilder: true, - SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainer, + SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainerForPolyglot, RunSyncOnBackgroundThread: false } \ No newline at end of file diff --git a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py index 5a8337affcb..19baf521fa8 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py +++ b/tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py @@ -110,6 +110,17 @@ class TestResourceStatus(str, Enum): # DTOs # ============================================================================ +@dataclass +class AddContainerOptions: + image: str + tag: str + + def to_dict(self) -> Dict[str, Any]: + return { + "Image": serialize_value(self.image), + "Tag": serialize_value(self.tag), + } + @dataclass class CreateBuilderOptions: args: list[str] @@ -152,6 +163,21 @@ def to_dict(self) -> Dict[str, Any]: "ExitCode": serialize_value(self.exit_code), } +@dataclass +class ReferenceEnvironmentInjectionOptions: + connection_string: bool + connection_properties: bool + service_discovery: bool + endpoints: bool + + def to_dict(self) -> Dict[str, Any]: + return { + "ConnectionString": serialize_value(self.connection_string), + "ConnectionProperties": serialize_value(self.connection_properties), + "ServiceDiscovery": serialize_value(self.service_discovery), + "Endpoints": serialize_value(self.endpoints), + } + @dataclass class CommandOptions: description: str @@ -173,6 +199,31 @@ def to_dict(self) -> Dict[str, Any]: "UpdateState": serialize_value(self.update_state), } +@dataclass +class GenerateParameterDefault: + min_length: float + lower: bool + upper: bool + numeric: bool + special: bool + min_lower: float + min_upper: float + min_numeric: float + min_special: float + + def to_dict(self) -> Dict[str, Any]: + return { + "MinLength": serialize_value(self.min_length), + "Lower": serialize_value(self.lower), + "Upper": serialize_value(self.upper), + "Numeric": serialize_value(self.numeric), + "Special": serialize_value(self.special), + "MinLower": serialize_value(self.min_lower), + "MinUpper": serialize_value(self.min_upper), + "MinNumeric": serialize_value(self.min_numeric), + "MinSpecial": serialize_value(self.min_special), + } + @dataclass class ExecuteCommandResult: success: bool @@ -414,6 +465,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -661,6 +718,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -992,8 +1056,8 @@ def with_required_command(self, command: str, help_link: str | None = None) -> I args["helpLink"] = serialize_value(help_link) return self._client.invoke_capability("Aspire.Hosting/withRequiredCommand", args) - def with_connection_property(self, name: str, value: ReferenceExpression) -> IResourceWithConnectionString: - """Adds a connection property with a reference expression""" + def with_connection_property(self, name: str, value: str | ReferenceExpression) -> IResourceWithConnectionString: + """Adds a connection property with a string or reference expression value""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) @@ -1114,6 +1178,13 @@ def with_command(self, name: str, display_name: str, execute_command: Callable[[ args["commandOptions"] = serialize_value(command_options) return self._client.invoke_capability("Aspire.Hosting/withCommand", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -1411,6 +1482,13 @@ def with_command(self, name: str, display_name: str, execute_command: Callable[[ args["commandOptions"] = serialize_value(command_options) return self._client.invoke_capability("Aspire.Hosting/withCommand", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -1681,12 +1759,12 @@ def with_container_name(self, name: str) -> ContainerResource: args["name"] = serialize_value(name) return self._client.invoke_capability("Aspire.Hosting/withContainerName", args) - def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResource: - """Adds a build argument from a parameter resource""" + def with_build_arg(self, name: str, value: str | ParameterResource) -> ContainerResource: + """Adds a build argument from a string value or parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" @@ -1695,6 +1773,17 @@ def with_build_secret(self, name: str, value: ParameterResource) -> ContainerRes args["value"] = serialize_value(value) return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) + def with_container_certificate_paths(self, custom_certificates_destination: str | None = None, default_certificate_bundle_paths: list[str] | None = None, default_certificate_directory_paths: list[str] | None = None) -> ContainerResource: + """Overrides container certificate bundle and directory paths used for trust configuration""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + if custom_certificates_destination is not None: + args["customCertificatesDestination"] = serialize_value(custom_certificates_destination) + if default_certificate_bundle_paths is not None: + args["defaultCertificateBundlePaths"] = serialize_value(default_certificate_bundle_paths) + if default_certificate_directory_paths is not None: + args["defaultCertificateDirectoryPaths"] = serialize_value(default_certificate_directory_paths) + return self._client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args) + def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -1806,6 +1895,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -2046,6 +2141,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -2536,6 +2638,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -2776,6 +2884,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -3298,6 +3413,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -3538,6 +3659,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -3918,6 +4046,13 @@ def with_command(self, name: str, display_name: str, execute_command: Callable[[ args["commandOptions"] = serialize_value(command_options) return self._client.invoke_capability("Aspire.Hosting/withCommand", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -4189,7 +4324,7 @@ def add_container_registry_from_string(self, name: str, endpoint: str, repositor args["repository"] = serialize_value(repository) return self._client.invoke_capability("Aspire.Hosting/addContainerRegistryFromString", args) - def add_container(self, name: str, image: str) -> ContainerResource: + def add_container(self, name: str, image: str | AddContainerOptions) -> ContainerResource: """Adds a container resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) @@ -4298,6 +4433,15 @@ def add_parameter_from_configuration(self, name: str, configuration_key: str, se args["secret"] = serialize_value(secret) return self._client.invoke_capability("Aspire.Hosting/addParameterFromConfiguration", args) + def add_parameter_with_generated_value(self, name: str, value: GenerateParameterDefault, secret: bool = False, persist: bool = False) -> ParameterResource: + """Adds a parameter with a generated default value""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["value"] = serialize_value(value) + args["secret"] = serialize_value(secret) + args["persist"] = serialize_value(persist) + return self._client.invoke_capability("Aspire.Hosting/addParameterWithGeneratedValue", args) + def add_connection_string(self, name: str, environment_variable_name: str | None = None) -> IResourceWithConnectionString: """Adds a connection string resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -4306,6 +4450,13 @@ def add_connection_string(self, name: str, environment_variable_name: str | None args["environmentVariableName"] = serialize_value(environment_variable_name) return self._client.invoke_capability("Aspire.Hosting/addConnectionString", args) + def add_project_without_launch_profile(self, name: str, project_path: str) -> ProjectResource: + """Adds a .NET project resource without a launch profile""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["name"] = serialize_value(name) + args["projectPath"] = serialize_value(project_path) + return self._client.invoke_capability("Aspire.Hosting/addProjectWithoutLaunchProfile", args) + def add_project(self, name: str, project_path: str, launch_profile_name: str) -> ProjectResource: """Adds a .NET project resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -4861,6 +5012,13 @@ def with_command(self, name: str, display_name: str, execute_command: Callable[[ args["commandOptions"] = serialize_value(command_options) return self._client.invoke_capability("Aspire.Hosting/withCommand", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -5460,6 +5618,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -5707,6 +5871,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -6346,12 +6517,12 @@ def with_container_name(self, name: str) -> ContainerResource: args["name"] = serialize_value(name) return self._client.invoke_capability("Aspire.Hosting/withContainerName", args) - def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResource: - """Adds a build argument from a parameter resource""" + def with_build_arg(self, name: str, value: str | ParameterResource) -> ContainerResource: + """Adds a build argument from a string value or parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" @@ -6360,6 +6531,17 @@ def with_build_secret(self, name: str, value: ParameterResource) -> ContainerRes args["value"] = serialize_value(value) return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) + def with_container_certificate_paths(self, custom_certificates_destination: str | None = None, default_certificate_bundle_paths: list[str] | None = None, default_certificate_directory_paths: list[str] | None = None) -> ContainerResource: + """Overrides container certificate bundle and directory paths used for trust configuration""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + if custom_certificates_destination is not None: + args["customCertificatesDestination"] = serialize_value(custom_certificates_destination) + if default_certificate_bundle_paths is not None: + args["defaultCertificateBundlePaths"] = serialize_value(default_certificate_bundle_paths) + if default_certificate_directory_paths is not None: + args["defaultCertificateDirectoryPaths"] = serialize_value(default_certificate_directory_paths) + return self._client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args) + def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -6471,6 +6653,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -6711,6 +6899,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7082,12 +7277,12 @@ def with_container_name(self, name: str) -> ContainerResource: args["name"] = serialize_value(name) return self._client.invoke_capability("Aspire.Hosting/withContainerName", args) - def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResource: - """Adds a build argument from a parameter resource""" + def with_build_arg(self, name: str, value: str | ParameterResource) -> ContainerResource: + """Adds a build argument from a string value or parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" @@ -7096,6 +7291,17 @@ def with_build_secret(self, name: str, value: ParameterResource) -> ContainerRes args["value"] = serialize_value(value) return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) + def with_container_certificate_paths(self, custom_certificates_destination: str | None = None, default_certificate_bundle_paths: list[str] | None = None, default_certificate_directory_paths: list[str] | None = None) -> ContainerResource: + """Overrides container certificate bundle and directory paths used for trust configuration""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + if custom_certificates_destination is not None: + args["customCertificatesDestination"] = serialize_value(custom_certificates_destination) + if default_certificate_bundle_paths is not None: + args["defaultCertificateBundlePaths"] = serialize_value(default_certificate_bundle_paths) + if default_certificate_directory_paths is not None: + args["defaultCertificateDirectoryPaths"] = serialize_value(default_certificate_directory_paths) + return self._client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args) + def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7185,8 +7391,8 @@ def with_environment_connection_string(self, env_var_name: str, resource: IResou args["resource"] = serialize_value(resource) return self._client.invoke_capability("Aspire.Hosting/withEnvironmentConnectionString", args) - def with_connection_property(self, name: str, value: ReferenceExpression) -> IResourceWithConnectionString: - """Adds a connection property with a reference expression""" + def with_connection_property(self, name: str, value: str | ReferenceExpression) -> IResourceWithConnectionString: + """Adds a connection property with a string or reference expression value""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) @@ -7221,6 +7427,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7467,6 +7679,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -7944,12 +8163,12 @@ def with_container_name(self, name: str) -> ContainerResource: args["name"] = serialize_value(name) return self._client.invoke_capability("Aspire.Hosting/withContainerName", args) - def with_build_arg(self, name: str, value: ParameterResource) -> ContainerResource: - """Adds a build argument from a parameter resource""" + def with_build_arg(self, name: str, value: str | ParameterResource) -> ContainerResource: + """Adds a build argument from a string value or parameter resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } args["name"] = serialize_value(name) args["value"] = serialize_value(value) - return self._client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args) + return self._client.invoke_capability("Aspire.Hosting/withBuildArg", args) def with_build_secret(self, name: str, value: ParameterResource) -> ContainerResource: """Adds a build secret from a parameter resource""" @@ -7958,6 +8177,17 @@ def with_build_secret(self, name: str, value: ParameterResource) -> ContainerRes args["value"] = serialize_value(value) return self._client.invoke_capability("Aspire.Hosting/withParameterBuildSecret", args) + def with_container_certificate_paths(self, custom_certificates_destination: str | None = None, default_certificate_bundle_paths: list[str] | None = None, default_certificate_directory_paths: list[str] | None = None) -> ContainerResource: + """Overrides container certificate bundle and directory paths used for trust configuration""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + if custom_certificates_destination is not None: + args["customCertificatesDestination"] = serialize_value(custom_certificates_destination) + if default_certificate_bundle_paths is not None: + args["defaultCertificateBundlePaths"] = serialize_value(default_certificate_bundle_paths) + if default_certificate_directory_paths is not None: + args["defaultCertificateDirectoryPaths"] = serialize_value(default_certificate_directory_paths) + return self._client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args) + def with_endpoint_proxy_support(self, proxy_enabled: bool) -> ContainerResource: """Configures endpoint proxy support""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -8069,6 +8299,12 @@ def with_args_callback_async(self, callback: Callable[[CommandLineArgsCallbackCo args["callback"] = callback_id return self._client.invoke_capability("Aspire.Hosting/withArgsCallbackAsync", args) + def with_reference_environment(self, options: ReferenceEnvironmentInjectionOptions) -> IResourceWithEnvironment: + """Configures which reference values are injected into environment variables""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["options"] = serialize_value(options) + return self._client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args) + def with_reference(self, source: IResource, connection_name: str | None = None, optional: bool = False, name: str | None = None) -> IResourceWithEnvironment: """Adds a reference to another resource""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } @@ -8309,6 +8545,13 @@ def without_https_certificate(self) -> IResourceWithEnvironment: args: Dict[str, Any] = { "builder": serialize_value(self._handle) } return self._client.invoke_capability("Aspire.Hosting/withoutHttpsCertificate", args) + def with_relationship(self, resource_builder: IResource, type: str) -> IResource: + """Adds a relationship to another resource""" + args: Dict[str, Any] = { "builder": serialize_value(self._handle) } + args["resourceBuilder"] = serialize_value(resource_builder) + args["type"] = serialize_value(type) + return self._client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args) + def with_parent_relationship(self, parent: IResource) -> IResource: """Sets the parent relationship""" args: Dict[str, Any] = { "builder": serialize_value(self._handle) } diff --git a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/HostingAddContainerCapability.verified.txt b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/HostingAddContainerCapability.verified.txt index aa3dae2c23d..61f69575bbb 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/HostingAddContainerCapability.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/HostingAddContainerCapability.verified.txt @@ -22,13 +22,34 @@ { Name: image, Type: { - TypeId: string, - ClrType: string, + TypeId: string|Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + Category: Union, IsInterface: false, IsReadOnly: false, IsResourceBuilder: false, IsDistributedApplicationBuilder: false, - IsDistributedApplication: false + IsDistributedApplication: false, + UnionTypes: [ + { + TypeId: string, + ClrType: string, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + }, + { + TypeId: Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + ClrType: AddContainerOptions, + Category: Dto, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + } + ] }, IsOptional: false, IsNullable: false, @@ -70,6 +91,6 @@ } ], ReturnsBuilder: true, - SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainer, + SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainerForPolyglot, RunSyncOnBackgroundThread: false } \ No newline at end of file diff --git a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs index 74126f7ea54..2c32cf46751 100644 --- a/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs +++ b/tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs @@ -385,6 +385,24 @@ impl std::fmt::Display for TestResourceStatus { // DTOs // ============================================================================ +/// AddContainerOptions +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +pub struct AddContainerOptions { + #[serde(rename = "Image")] + pub image: String, + #[serde(rename = "Tag")] + pub tag: String, +} + +impl AddContainerOptions { + pub fn to_map(&self) -> HashMap { + let mut map = HashMap::new(); + map.insert("Image".to_string(), serde_json::to_value(&self.image).unwrap_or(Value::Null)); + map.insert("Tag".to_string(), serde_json::to_value(&self.tag).unwrap_or(Value::Null)); + map + } +} + /// CreateBuilderOptions #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct CreateBuilderOptions { @@ -451,6 +469,30 @@ impl ResourceEventDto { } } +/// ReferenceEnvironmentInjectionOptions +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +pub struct ReferenceEnvironmentInjectionOptions { + #[serde(rename = "ConnectionString")] + pub connection_string: bool, + #[serde(rename = "ConnectionProperties")] + pub connection_properties: bool, + #[serde(rename = "ServiceDiscovery")] + pub service_discovery: bool, + #[serde(rename = "Endpoints")] + pub endpoints: bool, +} + +impl ReferenceEnvironmentInjectionOptions { + pub fn to_map(&self) -> HashMap { + let mut map = HashMap::new(); + map.insert("ConnectionString".to_string(), serde_json::to_value(&self.connection_string).unwrap_or(Value::Null)); + map.insert("ConnectionProperties".to_string(), serde_json::to_value(&self.connection_properties).unwrap_or(Value::Null)); + map.insert("ServiceDiscovery".to_string(), serde_json::to_value(&self.service_discovery).unwrap_or(Value::Null)); + map.insert("Endpoints".to_string(), serde_json::to_value(&self.endpoints).unwrap_or(Value::Null)); + map + } +} + /// CommandOptions #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct CommandOptions { @@ -484,6 +526,45 @@ impl CommandOptions { } } +/// GenerateParameterDefault +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +pub struct GenerateParameterDefault { + #[serde(rename = "MinLength")] + pub min_length: f64, + #[serde(rename = "Lower")] + pub lower: bool, + #[serde(rename = "Upper")] + pub upper: bool, + #[serde(rename = "Numeric")] + pub numeric: bool, + #[serde(rename = "Special")] + pub special: bool, + #[serde(rename = "MinLower")] + pub min_lower: f64, + #[serde(rename = "MinUpper")] + pub min_upper: f64, + #[serde(rename = "MinNumeric")] + pub min_numeric: f64, + #[serde(rename = "MinSpecial")] + pub min_special: f64, +} + +impl GenerateParameterDefault { + pub fn to_map(&self) -> HashMap { + let mut map = HashMap::new(); + map.insert("MinLength".to_string(), serde_json::to_value(&self.min_length).unwrap_or(Value::Null)); + map.insert("Lower".to_string(), serde_json::to_value(&self.lower).unwrap_or(Value::Null)); + map.insert("Upper".to_string(), serde_json::to_value(&self.upper).unwrap_or(Value::Null)); + map.insert("Numeric".to_string(), serde_json::to_value(&self.numeric).unwrap_or(Value::Null)); + map.insert("Special".to_string(), serde_json::to_value(&self.special).unwrap_or(Value::Null)); + map.insert("MinLower".to_string(), serde_json::to_value(&self.min_lower).unwrap_or(Value::Null)); + map.insert("MinUpper".to_string(), serde_json::to_value(&self.min_upper).unwrap_or(Value::Null)); + map.insert("MinNumeric".to_string(), serde_json::to_value(&self.min_numeric).unwrap_or(Value::Null)); + map.insert("MinSpecial".to_string(), serde_json::to_value(&self.min_special).unwrap_or(Value::Null)); + map + } +} + /// ExecuteCommandResult #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct ExecuteCommandResult { @@ -945,6 +1026,16 @@ impl CSharpAppResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -1345,6 +1436,17 @@ impl CSharpAppResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -1901,8 +2003,8 @@ impl ConnectionStringResource { Ok(IResource::new(handle, self.client.clone())) } - /// Adds a connection property with a reference expression - pub fn with_connection_property(&self, name: &str, value: ReferenceExpression) -> Result> { + /// Adds a connection property with a string or reference expression value + pub fn with_connection_property(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); @@ -2091,6 +2193,17 @@ impl ConnectionStringResource { Ok(IResource::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -2568,6 +2681,17 @@ impl ContainerRegistryResource { Ok(IResource::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -3014,13 +3138,13 @@ impl ContainerResource { Ok(ContainerResource::new(handle, self.client.clone())) } - /// Adds a build argument from a parameter resource - pub fn with_build_arg(&self, name: &str, value: &ParameterResource) -> Result> { + /// Adds a build argument from a string value or parameter resource + pub fn with_build_arg(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -3036,6 +3160,24 @@ impl ContainerResource { Ok(ContainerResource::new(handle, self.client.clone())) } + /// Overrides container certificate bundle and directory paths used for trust configuration + pub fn with_container_certificate_paths(&self, custom_certificates_destination: Option<&str>, default_certificate_bundle_paths: Option>, default_certificate_directory_paths: Option>) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + if let Some(ref v) = custom_certificates_destination { + args.insert("customCertificatesDestination".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_bundle_paths { + args.insert("defaultCertificateBundlePaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_directory_paths { + args.insert("defaultCertificateDirectoryPaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + let result = self.client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(ContainerResource::new(handle, self.client.clone())) + } + /// Configures endpoint proxy support pub fn with_endpoint_proxy_support(&self, proxy_enabled: bool) -> Result> { let mut args: HashMap = HashMap::new(); @@ -3214,6 +3356,16 @@ impl ContainerResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -3603,6 +3755,17 @@ impl ContainerResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -4500,6 +4663,16 @@ impl DotnetToolResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -4889,6 +5062,17 @@ impl DotnetToolResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -5774,6 +5958,16 @@ impl ExecutableResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -6163,6 +6357,17 @@ impl ExecutableResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -6792,6 +6997,17 @@ impl ExternalServiceResource { Ok(IResource::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -7298,7 +7514,7 @@ impl IDistributedApplicationBuilder { } /// Adds a container resource - pub fn add_container(&self, name: &str, image: &str) -> Result> { + pub fn add_container(&self, name: &str, image: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); @@ -7479,6 +7695,23 @@ impl IDistributedApplicationBuilder { Ok(ParameterResource::new(handle, self.client.clone())) } + /// Adds a parameter with a generated default value + pub fn add_parameter_with_generated_value(&self, name: &str, value: GenerateParameterDefault, secret: Option, persist: Option) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + if let Some(ref v) = secret { + args.insert("secret".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = persist { + args.insert("persist".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + let result = self.client.invoke_capability("Aspire.Hosting/addParameterWithGeneratedValue", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(ParameterResource::new(handle, self.client.clone())) + } + /// Adds a connection string resource pub fn add_connection_string(&self, name: &str, environment_variable_name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -7492,6 +7725,17 @@ impl IDistributedApplicationBuilder { Ok(IResourceWithConnectionString::new(handle, self.client.clone())) } + /// Adds a .NET project resource without a launch profile + pub fn add_project_without_launch_profile(&self, name: &str, project_path: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); + args.insert("projectPath".to_string(), serde_json::to_value(&project_path).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/addProjectWithoutLaunchProfile", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(ProjectResource::new(handle, self.client.clone())) + } + /// Adds a .NET project resource pub fn add_project(&self, name: &str, project_path: &str, launch_profile_name: &str) -> Result> { let mut args: HashMap = HashMap::new(); @@ -8702,6 +8946,17 @@ impl ParameterResource { Ok(IResource::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -9754,6 +10009,16 @@ impl ProjectResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -10154,6 +10419,17 @@ impl ProjectResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -11301,13 +11577,13 @@ impl TestDatabaseResource { Ok(ContainerResource::new(handle, self.client.clone())) } - /// Adds a build argument from a parameter resource - pub fn with_build_arg(&self, name: &str, value: &ParameterResource) -> Result> { + /// Adds a build argument from a string value or parameter resource + pub fn with_build_arg(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -11323,6 +11599,24 @@ impl TestDatabaseResource { Ok(ContainerResource::new(handle, self.client.clone())) } + /// Overrides container certificate bundle and directory paths used for trust configuration + pub fn with_container_certificate_paths(&self, custom_certificates_destination: Option<&str>, default_certificate_bundle_paths: Option>, default_certificate_directory_paths: Option>) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + if let Some(ref v) = custom_certificates_destination { + args.insert("customCertificatesDestination".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_bundle_paths { + args.insert("defaultCertificateBundlePaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_directory_paths { + args.insert("defaultCertificateDirectoryPaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + let result = self.client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(ContainerResource::new(handle, self.client.clone())) + } + /// Configures endpoint proxy support pub fn with_endpoint_proxy_support(&self, proxy_enabled: bool) -> Result> { let mut args: HashMap = HashMap::new(); @@ -11501,6 +11795,16 @@ impl TestDatabaseResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -11890,6 +12194,17 @@ impl TestDatabaseResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -12515,13 +12830,13 @@ impl TestRedisResource { Ok(ContainerResource::new(handle, self.client.clone())) } - /// Adds a build argument from a parameter resource - pub fn with_build_arg(&self, name: &str, value: &ParameterResource) -> Result> { + /// Adds a build argument from a string value or parameter resource + pub fn with_build_arg(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -12537,6 +12852,24 @@ impl TestRedisResource { Ok(ContainerResource::new(handle, self.client.clone())) } + /// Overrides container certificate bundle and directory paths used for trust configuration + pub fn with_container_certificate_paths(&self, custom_certificates_destination: Option<&str>, default_certificate_bundle_paths: Option>, default_certificate_directory_paths: Option>) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + if let Some(ref v) = custom_certificates_destination { + args.insert("customCertificatesDestination".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_bundle_paths { + args.insert("defaultCertificateBundlePaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_directory_paths { + args.insert("defaultCertificateDirectoryPaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + let result = self.client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(ContainerResource::new(handle, self.client.clone())) + } + /// Configures endpoint proxy support pub fn with_endpoint_proxy_support(&self, proxy_enabled: bool) -> Result> { let mut args: HashMap = HashMap::new(); @@ -12683,8 +13016,8 @@ impl TestRedisResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } - /// Adds a connection property with a reference expression - pub fn with_connection_property(&self, name: &str, value: ReferenceExpression) -> Result> { + /// Adds a connection property with a string or reference expression value + pub fn with_connection_property(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); @@ -12737,6 +13070,16 @@ impl TestRedisResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -13135,6 +13478,17 @@ impl TestRedisResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); @@ -13902,13 +14256,13 @@ impl TestVaultResource { Ok(ContainerResource::new(handle, self.client.clone())) } - /// Adds a build argument from a parameter resource - pub fn with_build_arg(&self, name: &str, value: &ParameterResource) -> Result> { + /// Adds a build argument from a string value or parameter resource + pub fn with_build_arg(&self, name: &str, value: Value) -> Result> { let mut args: HashMap = HashMap::new(); args.insert("builder".to_string(), self.handle.to_json()); args.insert("name".to_string(), serde_json::to_value(&name).unwrap_or(Value::Null)); - args.insert("value".to_string(), value.handle().to_json()); - let result = self.client.invoke_capability("Aspire.Hosting/withParameterBuildArg", args)?; + args.insert("value".to_string(), serde_json::to_value(&value).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuildArg", args)?; let handle: Handle = serde_json::from_value(result)?; Ok(ContainerResource::new(handle, self.client.clone())) } @@ -13924,6 +14278,24 @@ impl TestVaultResource { Ok(ContainerResource::new(handle, self.client.clone())) } + /// Overrides container certificate bundle and directory paths used for trust configuration + pub fn with_container_certificate_paths(&self, custom_certificates_destination: Option<&str>, default_certificate_bundle_paths: Option>, default_certificate_directory_paths: Option>) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + if let Some(ref v) = custom_certificates_destination { + args.insert("customCertificatesDestination".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_bundle_paths { + args.insert("defaultCertificateBundlePaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + if let Some(ref v) = default_certificate_directory_paths { + args.insert("defaultCertificateDirectoryPaths".to_string(), serde_json::to_value(v).unwrap_or(Value::Null)); + } + let result = self.client.invoke_capability("Aspire.Hosting/withContainerCertificatePaths", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(ContainerResource::new(handle, self.client.clone())) + } + /// Configures endpoint proxy support pub fn with_endpoint_proxy_support(&self, proxy_enabled: bool) -> Result> { let mut args: HashMap = HashMap::new(); @@ -14102,6 +14474,16 @@ impl TestVaultResource { Ok(IResourceWithArgs::new(handle, self.client.clone())) } + /// Configures which reference values are injected into environment variables + pub fn with_reference_environment(&self, options: ReferenceEnvironmentInjectionOptions) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("options".to_string(), serde_json::to_value(&options).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withReferenceEnvironment", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResourceWithEnvironment::new(handle, self.client.clone())) + } + /// Adds a reference to another resource pub fn with_reference(&self, source: &IResource, connection_name: Option<&str>, optional: Option, name: Option<&str>) -> Result> { let mut args: HashMap = HashMap::new(); @@ -14491,6 +14873,17 @@ impl TestVaultResource { Ok(IResourceWithEnvironment::new(handle, self.client.clone())) } + /// Adds a relationship to another resource + pub fn with_relationship(&self, resource_builder: &IResource, r#type: &str) -> Result> { + let mut args: HashMap = HashMap::new(); + args.insert("builder".to_string(), self.handle.to_json()); + args.insert("resourceBuilder".to_string(), resource_builder.handle().to_json()); + args.insert("type".to_string(), serde_json::to_value(&r#type).unwrap_or(Value::Null)); + let result = self.client.invoke_capability("Aspire.Hosting/withBuilderRelationship", args)?; + let handle: Handle = serde_json::from_value(result)?; + Ok(IResource::new(handle, self.client.clone())) + } + /// Sets the parent relationship pub fn with_parent_relationship(&self, parent: &IResource) -> Result> { let mut args: HashMap = HashMap::new(); diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingAddContainerCapability.verified.txt b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingAddContainerCapability.verified.txt index aa3dae2c23d..61f69575bbb 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingAddContainerCapability.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingAddContainerCapability.verified.txt @@ -22,13 +22,34 @@ { Name: image, Type: { - TypeId: string, - ClrType: string, + TypeId: string|Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + Category: Union, IsInterface: false, IsReadOnly: false, IsResourceBuilder: false, IsDistributedApplicationBuilder: false, - IsDistributedApplication: false + IsDistributedApplication: false, + UnionTypes: [ + { + TypeId: string, + ClrType: string, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + }, + { + TypeId: Aspire.Hosting/Aspire.Hosting.Ats.AddContainerOptions, + ClrType: AddContainerOptions, + Category: Dto, + IsInterface: false, + IsReadOnly: false, + IsResourceBuilder: false, + IsDistributedApplicationBuilder: false, + IsDistributedApplication: false + } + ] }, IsOptional: false, IsNullable: false, @@ -70,6 +91,6 @@ } ], ReturnsBuilder: true, - SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainer, + SourceLocation: Aspire.Hosting.ContainerResourceBuilderExtensions.AddContainerForPolyglot, RunSyncOnBackgroundThread: false } \ No newline at end of file diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt index b287abc55c8..981fd70c71d 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt @@ -293,6 +293,20 @@ } ] }, + { + CapabilityId: Aspire.Hosting/withBuildArg, + MethodName: withBuildArg, + TargetType: { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + }, + ExpandedTargetTypes: [ + { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + } + ] + }, { CapabilityId: Aspire.Hosting/withBuilderChildRelationship, MethodName: withChildRelationship, @@ -321,6 +335,20 @@ } ] }, + { + CapabilityId: Aspire.Hosting/withBuilderRelationship, + MethodName: withRelationship, + TargetType: { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource, + IsInterface: true + }, + ExpandedTargetTypes: [ + { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + } + ] + }, { CapabilityId: Aspire.Hosting/withCertificateTrustScope, MethodName: withCertificateTrustScope, @@ -349,6 +377,20 @@ } ] }, + { + CapabilityId: Aspire.Hosting/withContainerCertificatePaths, + MethodName: withContainerCertificatePaths, + TargetType: { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + }, + ExpandedTargetTypes: [ + { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + } + ] + }, { CapabilityId: Aspire.Hosting/withContainerName, MethodName: withContainerName, @@ -811,20 +853,6 @@ } ] }, - { - CapabilityId: Aspire.Hosting/withParameterBuildArg, - MethodName: withBuildArg, - TargetType: { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false - }, - ExpandedTargetTypes: [ - { - TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, - IsInterface: false - } - ] - }, { CapabilityId: Aspire.Hosting/withParameterBuildSecret, MethodName: withBuildSecret, @@ -923,6 +951,20 @@ } ] }, + { + CapabilityId: Aspire.Hosting/withReferenceEnvironment, + MethodName: withReferenceEnvironment, + TargetType: { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResourceWithEnvironment, + IsInterface: true + }, + ExpandedTargetTypes: [ + { + TypeId: Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource, + IsInterface: false + } + ] + }, { CapabilityId: Aspire.Hosting/withReferenceExternalService, MethodName: withReferenceExternalService, diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts index 8eb9945b420..f818a0c3923 100644 --- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts +++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts @@ -362,6 +362,12 @@ export enum WaitBehavior { // DTO Interfaces // ============================================================================ +/** DTO interface for AddContainerOptions */ +export interface AddContainerOptions { + image?: string; + tag?: string; +} + /** DTO interface for CommandOptions */ export interface CommandOptions { description?: string; @@ -392,6 +398,27 @@ export interface ExecuteCommandResult { errorMessage?: string; } +/** 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 ReferenceEnvironmentInjectionOptions */ +export interface ReferenceEnvironmentInjectionOptions { + connectionString?: boolean; + connectionProperties?: boolean; + serviceDiscovery?: boolean; + endpoints?: boolean; +} + /** DTO interface for ResourceEventDto */ export interface ResourceEventDto { resourceName?: string; @@ -461,6 +488,11 @@ export interface AddParameterOptions { secret?: boolean; } +export interface AddParameterWithGeneratedValueOptions { + secret?: boolean; + persist?: boolean; +} + export interface AddParameterWithValueOptions { publishValueAsDefault?: boolean; secret?: boolean; @@ -564,6 +596,12 @@ export interface WithCommandOptions { commandOptions?: CommandOptions; } +export interface WithContainerCertificatePathsOptions { + customCertificatesDestination?: string; + defaultCertificateBundlePaths?: string[]; + defaultCertificateDirectoryPaths?: string[]; +} + export interface WithDataVolumeOptions { name?: string; isReadOnly?: boolean; @@ -3221,7 +3259,7 @@ export class DistributedApplicationBuilder { /** Adds a container resource */ /** @internal */ - async _addContainerInternal(name: string, image: string): Promise { + 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', @@ -3230,7 +3268,7 @@ export class DistributedApplicationBuilder { return new ContainerResource(result, this._client); } - addContainer(name: string, image: string): ContainerResourcePromise { + addContainer(name: string, image: string | AddContainerOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._addContainerInternal(name, image)); } @@ -3381,6 +3419,25 @@ export class DistributedApplicationBuilder { return new ParameterResourcePromise(this._addParameterFromConfigurationInternal(name, configurationKey, secret)); } + /** Adds a parameter with a generated default value */ + /** @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 ParameterResource(result, this._client); + } + + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + const secret = options?.secret; + const persist = options?.persist; + return new ParameterResourcePromise(this._addParameterWithGeneratedValueInternal(name, value, secret, persist)); + } + /** Adds a connection string resource */ /** @internal */ async _addConnectionStringInternal(name: string, environmentVariableName?: string): Promise { @@ -3398,6 +3455,21 @@ export class DistributedApplicationBuilder { return new ResourceWithConnectionStringPromise(this._addConnectionStringInternal(name, environmentVariableName)); } + /** Adds a .NET project resource without a launch profile */ + /** @internal */ + async _addProjectWithoutLaunchProfileInternal(name: string, projectPath: string): Promise { + const rpcArgs: Record = { builder: this._handle, name, projectPath }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/addProjectWithoutLaunchProfile', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._addProjectWithoutLaunchProfileInternal(name, projectPath)); + } + /** Adds a .NET project resource */ /** @internal */ async _addProjectInternal(name: string, projectPath: string, launchProfileName: string): Promise { @@ -3584,7 +3656,7 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addContainer(name, image))); } @@ -3633,11 +3705,21 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addParameterFromConfiguration(name, configurationKey, options))); } + /** Adds a parameter with a generated default value */ + addParameterWithGeneratedValue(name: string, value: GenerateParameterDefault, options?: AddParameterWithGeneratedValueOptions): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.addParameterWithGeneratedValue(name, value, options))); + } + /** Adds a connection string resource */ addConnectionString(name: string, options?: AddConnectionStringOptions): ResourceWithConnectionStringPromise { return new ResourceWithConnectionStringPromise(this._promise.then(obj => obj.addConnectionString(name, options))); } + /** Adds a .NET project resource without a launch profile */ + addProjectWithoutLaunchProfile(name: string, projectPath: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.addProjectWithoutLaunchProfile(name, projectPath))); + } + /** Adds a .NET project resource */ addProject(name: string, projectPath: string, launchProfileName: string): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.addProject(name, projectPath, launchProfileName))); @@ -4604,7 +4686,7 @@ export class ConnectionStringResource extends ResourceBuilderBase { + 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', @@ -4613,8 +4695,8 @@ export class ConnectionStringResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ConnectionStringResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -5395,8 +5492,8 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withRequiredCommand(command, options))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): ConnectionStringResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -5480,6 +5577,11 @@ export class ConnectionStringResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ConnectionStringResourcePromise { + return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ConnectionStringResourcePromise { return new ConnectionStringResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -5842,6 +5944,21 @@ export class ContainerRegistryResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerRegistryResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -6353,6 +6470,11 @@ export class ContainerRegistryResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerRegistryResourcePromise { + return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerRegistryResourcePromise { return new ContainerRegistryResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -6693,17 +6815,17 @@ export class ContainerResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterBuildArg', + 'Aspire.Hosting/withBuildArg', rpcArgs ); return new ContainerResource(result, this._client); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._withBuildArgInternal(name, value)); } @@ -6722,6 +6844,27 @@ export class ContainerResource extends ResourceBuilderBase { + 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 ContainerResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new ContainerResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -6987,6 +7130,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -7513,6 +7671,21 @@ export class ContainerResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ContainerResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -8162,8 +8335,8 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): ContainerResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -8172,6 +8345,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -8252,6 +8430,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -8402,6 +8585,11 @@ export class ContainerResourcePromise implements PromiseLike return new ContainerResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ContainerResourcePromise { + return new ContainerResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ContainerResourcePromise { return new ContainerResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -8860,6 +9048,21 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -9401,6 +9604,21 @@ export class CSharpAppResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new CSharpAppResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -10051,6 +10269,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -10206,6 +10429,11 @@ export class CSharpAppResourcePromise implements PromiseLike return new CSharpAppResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): CSharpAppResourcePromise { + return new CSharpAppResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): CSharpAppResourcePromise { return new CSharpAppResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -10762,6 +10990,21 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -11288,6 +11531,21 @@ export class DotnetToolResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new DotnetToolResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -11973,6 +12231,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -12123,6 +12386,11 @@ export class DotnetToolResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): DotnetToolResourcePromise { + return new DotnetToolResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): DotnetToolResourcePromise { return new DotnetToolResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -12589,6 +12857,21 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -13115,6 +13398,21 @@ export class ExecutableResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExecutableResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -13770,6 +14068,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -13920,6 +14223,11 @@ export class ExecutableResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExecutableResourcePromise { + return new ExecutableResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExecutableResourcePromise { return new ExecutableResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -14316,6 +14624,21 @@ export class ExternalServiceResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ExternalServiceResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -14832,6 +15155,11 @@ export class ExternalServiceResourcePromise implements PromiseLike obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ExternalServiceResourcePromise { + return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ExternalServiceResourcePromise { return new ExternalServiceResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -15196,6 +15524,21 @@ export class ParameterResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ParameterResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -15712,6 +16055,11 @@ export class ParameterResourcePromise implements PromiseLike return new ParameterResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ParameterResourcePromise { + return new ParameterResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ParameterResourcePromise { return new ParameterResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -16135,6 +16483,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withArgsCallbackAsyncInternal(callback)); } + /** @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 ProjectResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -16676,6 +17039,21 @@ export class ProjectResource extends ResourceBuilderBase return new ProjectResourcePromise(this._withoutHttpsCertificateInternal()); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new ProjectResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -17326,6 +17704,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -17481,6 +17864,11 @@ export class ProjectResourcePromise implements PromiseLike { return new ProjectResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ProjectResourcePromise { + return new ProjectResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ProjectResourcePromise { return new ProjectResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -17851,17 +18239,17 @@ export class TestDatabaseResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterBuildArg', + 'Aspire.Hosting/withBuildArg', rpcArgs ); return new TestDatabaseResource(result, this._client); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestDatabaseResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._withBuildArgInternal(name, value)); } @@ -17880,6 +18268,27 @@ export class TestDatabaseResource extends ResourceBuilderBase { + 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 TestDatabaseResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): TestDatabaseResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new TestDatabaseResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -18145,6 +18554,21 @@ export class TestDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new TestDatabaseResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -18671,6 +19095,21 @@ export class TestDatabaseResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new TestDatabaseResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -19320,8 +19759,8 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestDatabaseResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -19330,6 +19769,11 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -19410,6 +19854,11 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -19560,6 +20009,11 @@ export class TestDatabaseResourcePromise implements PromiseLike obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): TestDatabaseResourcePromise { + return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): TestDatabaseResourcePromise { return new TestDatabaseResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -19935,17 +20389,17 @@ export class TestRedisResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterBuildArg', + 'Aspire.Hosting/withBuildArg', rpcArgs ); return new TestRedisResource(result, this._client); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._withBuildArgInternal(name, value)); } @@ -19964,6 +20418,27 @@ export class TestRedisResource extends ResourceBuilderBase { + 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 TestRedisResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): TestRedisResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new TestRedisResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -20175,7 +20650,7 @@ export class TestRedisResource extends ResourceBuilderBase { + 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', @@ -20184,8 +20659,8 @@ export class TestRedisResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new TestRedisResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -20794,6 +21284,21 @@ export class TestRedisResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new TestRedisResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -21632,8 +22137,8 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestRedisResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -21642,6 +22147,11 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -21707,8 +22217,8 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withEnvironmentConnectionString(envVarName, resource))); } - /** Adds a connection property with a reference expression */ - withConnectionProperty(name: string, value: ReferenceExpression): TestRedisResourcePromise { + /** Adds a connection property with a string or reference expression value */ + withConnectionProperty(name: string, value: string | ReferenceExpression): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withConnectionProperty(name, value))); } @@ -21732,6 +22242,11 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -21887,6 +22402,11 @@ export class TestRedisResourcePromise implements PromiseLike return new TestRedisResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): TestRedisResourcePromise { + return new TestRedisResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): TestRedisResourcePromise { return new TestRedisResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -22327,17 +22847,17 @@ export class TestVaultResource extends ResourceBuilderBase { + private async _withBuildArgInternal(name: string, value: string | ParameterResource): Promise { const rpcArgs: Record = { builder: this._handle, name, value }; const result = await this._client.invokeCapability( - 'Aspire.Hosting/withParameterBuildArg', + 'Aspire.Hosting/withBuildArg', rpcArgs ); return new TestVaultResource(result, this._client); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._withBuildArgInternal(name, value)); } @@ -22356,6 +22876,27 @@ export class TestVaultResource extends ResourceBuilderBase { + 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 TestVaultResource(result, this._client); + } + + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): TestVaultResourcePromise { + const customCertificatesDestination = options?.customCertificatesDestination; + const defaultCertificateBundlePaths = options?.defaultCertificateBundlePaths; + const defaultCertificateDirectoryPaths = options?.defaultCertificateDirectoryPaths; + return new TestVaultResourcePromise(this._withContainerCertificatePathsInternal(customCertificatesDestination, defaultCertificateBundlePaths, defaultCertificateDirectoryPaths)); + } + /** @internal */ private async _withEndpointProxySupportInternal(proxyEnabled: boolean): Promise { const rpcArgs: Record = { builder: this._handle, proxyEnabled }; @@ -22621,6 +23162,21 @@ export class TestVaultResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new TestVaultResource(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -23147,6 +23703,21 @@ export class TestVaultResource extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new TestVaultResource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -23811,8 +24382,8 @@ export class TestVaultResourcePromise implements PromiseLike return new TestVaultResourcePromise(this._promise.then(obj => obj.withContainerName(name))); } - /** Adds a build argument from a parameter resource */ - withBuildArg(name: string, value: ParameterResource): TestVaultResourcePromise { + /** Adds a build argument from a string value or parameter resource */ + withBuildArg(name: string, value: string | ParameterResource): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withBuildArg(name, value))); } @@ -23821,6 +24392,11 @@ export class TestVaultResourcePromise implements PromiseLike return new TestVaultResourcePromise(this._promise.then(obj => obj.withBuildSecret(name, value))); } + /** Overrides container certificate bundle and directory paths used for trust configuration */ + withContainerCertificatePaths(options?: WithContainerCertificatePathsOptions): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withContainerCertificatePaths(options))); + } + /** Configures endpoint proxy support */ withEndpointProxySupport(proxyEnabled: boolean): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withEndpointProxySupport(proxyEnabled))); @@ -23901,6 +24477,11 @@ export class TestVaultResourcePromise implements PromiseLike return new TestVaultResourcePromise(this._promise.then(obj => obj.withArgsCallbackAsync(callback))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withReference(source, options))); @@ -24051,6 +24632,11 @@ export class TestVaultResourcePromise implements PromiseLike return new TestVaultResourcePromise(this._promise.then(obj => obj.withoutHttpsCertificate())); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): TestVaultResourcePromise { + return new TestVaultResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): TestVaultResourcePromise { return new TestVaultResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -24554,6 +25140,21 @@ export class Resource extends ResourceBuilderBase { return new ResourcePromise(this._withCommandInternal(name, displayName, executeCommand, commandOptions)); } + /** @internal */ + private async _withRelationshipInternal(resourceBuilder: ResourceBuilderBase, type: string): Promise { + const rpcArgs: Record = { builder: this._handle, resourceBuilder, type }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withBuilderRelationship', + rpcArgs + ); + return new Resource(result, this._client); + } + + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._withRelationshipInternal(resourceBuilder, type)); + } + /** @internal */ private async _withParentRelationshipInternal(parent: ResourceBuilderBase): Promise { const rpcArgs: Record = { builder: this._handle, parent }; @@ -25065,6 +25666,11 @@ export class ResourcePromise implements PromiseLike { return new ResourcePromise(this._promise.then(obj => obj.withCommand(name, displayName, executeCommand, options))); } + /** Adds a relationship to another resource */ + withRelationship(resourceBuilder: ResourceBuilderBase, type: string): ResourcePromise { + return new ResourcePromise(this._promise.then(obj => obj.withRelationship(resourceBuilder, type))); + } + /** Sets the parent relationship */ withParentRelationship(parent: ResourceBuilderBase): ResourcePromise { return new ResourcePromise(this._promise.then(obj => obj.withParentRelationship(parent))); @@ -25300,7 +25906,7 @@ export class ResourceWithConnectionString extends ResourceBuilderBase { + 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', @@ -25309,8 +25915,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase obj.withConnectionProperty(name, value))); } @@ -25936,6 +26542,21 @@ export class ResourceWithEnvironment extends ResourceBuilderBase { + const rpcArgs: Record = { builder: this._handle, options }; + const result = await this._client.invokeCapability( + 'Aspire.Hosting/withReferenceEnvironment', + rpcArgs + ); + return new ResourceWithEnvironment(result, this._client); + } + + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._withReferenceEnvironmentInternal(options)); + } + /** @internal */ private async _withReferenceInternal(source: ResourceBuilderBase, connectionName?: string, optional?: boolean, name?: string): Promise { const rpcArgs: Record = { builder: this._handle, source }; @@ -26151,6 +26772,11 @@ export class ResourceWithEnvironmentPromise implements PromiseLike obj.withEnvironmentConnectionString(envVarName, resource))); } + /** Configures which reference values are injected into environment variables */ + withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): ResourceWithEnvironmentPromise { + return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReferenceEnvironment(options))); + } + /** Adds a reference to another resource */ withReference(source: ResourceBuilderBase, options?: WithReferenceOptions): ResourceWithEnvironmentPromise { return new ResourceWithEnvironmentPromise(this._promise.then(obj => obj.withReference(source, options))); From 26d61e1f5f488ec35a50a6305a30b43e70e77201 Mon Sep 17 00:00:00 2001 From: "aspire-repo-bot[bot]" <268009190+aspire-repo-bot[bot]@users.noreply.github.com> Date: Fri, 27 Mar 2026 10:22:38 -0700 Subject: [PATCH 48/49] [release/13.2] Fix migration from .aspire/settings.json to aspire.config.json (#15526) * Fix migration from .aspire/settings.json to aspire.config.json When the AppHost was found from legacy .aspire/settings.json, the UseOrFindAppHostProjectFileAsync method returned early without calling CreateSettingsFileAsync, so the migration to aspire.config.json never triggered. This fix ensures CreateSettingsFileAsync is called when createSettingsFile is true and the AppHost is found from settings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix migration test to use correct relative path Address Copilot review feedback: compute appHostPath relative to .aspire/ directory (not workspace root), normalize to forward slashes, and add a decoy project to ensure the legacy-settings resolution path is actually exercised rather than falling through to directory scanning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Mitch Denny Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Aspire.Cli/Projects/ProjectLocator.cs | 5 ++ .../Projects/ProjectLocatorTests.cs | 50 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/Aspire.Cli/Projects/ProjectLocator.cs b/src/Aspire.Cli/Projects/ProjectLocator.cs index 889b5f7aa1c..aa1f6dc5ee6 100644 --- a/src/Aspire.Cli/Projects/ProjectLocator.cs +++ b/src/Aspire.Cli/Projects/ProjectLocator.cs @@ -347,6 +347,11 @@ public async Task UseOrFindAppHostProjectFileAsync(F if (projectFile is not null) { + if (createSettingsFile) + { + await CreateSettingsFileAsync(projectFile, cancellationToken); + } + return new AppHostProjectSearchResult(projectFile, [projectFile]); } diff --git a/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs b/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs index 9003a67c8f4..108dc42e90e 100644 --- a/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs +++ b/tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs @@ -316,6 +316,56 @@ public async Task CreateSettingsFileIfNotExistsAsync_UsesForwardSlashPathSeparat Assert.Contains('/', settings.AppHost.Path); // Ensure forward slashes } + [Fact] + public async Task UseOrFindAppHostProjectFile_MigratesLegacySettingsToAspireConfigJson() + { + // Arrange: create a workspace with a legacy .aspire/settings.json + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var appHostDirectory = workspace.WorkspaceRoot.CreateSubdirectory("MyAppHost"); + var appHostProjectFile = new FileInfo(Path.Combine(appHostDirectory.FullName, "MyAppHost.csproj")); + await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real apphost"); + + // Add a decoy project so that a directory scan fallback would have another candidate + var decoyAppHostDirectory = workspace.WorkspaceRoot.CreateSubdirectory("DecoyAppHost"); + var decoyAppHostProjectFile = new FileInfo(Path.Combine(decoyAppHostDirectory.FullName, "DecoyAppHost.csproj")); + await File.WriteAllTextAsync(decoyAppHostProjectFile.FullName, "Not a real apphost"); + + var executionContext = CreateExecutionContext(workspace.WorkspaceRoot); + + // Write legacy .aspire/settings.json with a valid appHostPath + // (CreateExecutionContext already created the .aspire directory) + var aspireSettingsDir = new DirectoryInfo(Path.Combine(workspace.WorkspaceRoot.FullName, ".aspire")); + var aspireSettingsFile = new FileInfo(Path.Combine(aspireSettingsDir.FullName, "settings.json")); + var relativeAppHostPath = Path + .GetRelativePath(aspireSettingsDir.FullName, appHostProjectFile.FullName) + .Replace(Path.DirectorySeparatorChar, '/'); + await File.WriteAllTextAsync(aspireSettingsFile.FullName, JsonSerializer.Serialize(new { appHostPath = relativeAppHostPath })); + + // Use real ConfigurationService so migration actually writes to disk + var globalSettingsFilePath = Path.Combine(workspace.WorkspaceRoot.FullName, ".aspire", "settings.global.json"); + var globalSettingsFile = new FileInfo(globalSettingsFilePath); + var config = new ConfigurationBuilder().Build(); + var configurationService = new ConfigurationService(config, executionContext, globalSettingsFile, NullLogger.Instance); + + var locator = CreateProjectLocator(executionContext, configurationService: configurationService); + + // Act + var foundAppHost = await locator.UseOrFindAppHostProjectFileAsync(null, createSettingsFile: true, CancellationToken.None).DefaultTimeout(); + + // Assert: correct AppHost was found (not the decoy, proving legacy settings were used) + Assert.NotNull(foundAppHost); + Assert.Equal(appHostProjectFile.FullName, foundAppHost.FullName); + + // Assert: aspire.config.json was created by migration + var aspireConfigFilePath = Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); + Assert.True(File.Exists(aspireConfigFilePath), "aspire.config.json should have been created by migration from .aspire/settings.json"); + + var configJson = await File.ReadAllTextAsync(aspireConfigFilePath); + var migratedConfig = JsonSerializer.Deserialize(configJson); + Assert.NotNull(migratedConfig?.AppHost?.Path); + } + [Fact] public async Task FindAppHostProjectFilesAsync_DiscoversSingleFileAppHostInRootDirectory() { From 2765695d5fdec0a8fc5602e673b78f417f0af140 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Mar 2026 20:37:31 +0000 Subject: [PATCH 49/49] [release/13.2] Update CI image from 1es-mariner-2 to build.azurelinux.3.amd64 (#15330) Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/ac46e493-5cd8-46f6-b032-96ff7fe82159 Co-authored-by: radical <1472+radical@users.noreply.github.com> --- eng/pipelines/templates/build_sign_native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/build_sign_native.yml b/eng/pipelines/templates/build_sign_native.yml index 5cd83286e13..7ee70558dae 100644 --- a/eng/pipelines/templates/build_sign_native.yml +++ b/eng/pipelines/templates/build_sign_native.yml @@ -45,7 +45,7 @@ jobs: os: windows ${{ if eq(parameters.agentOs, 'linux') }}: name: NetCore1ESPool-Internal - image: 1es-mariner-2 + image: build.azurelinux.3.amd64 os: linux ${{ if eq(parameters.agentOs, 'macos') }}: name: Azure Pipelines